Boost logo

Boost Users :

Subject: [Boost-users] [thread] call_once question
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2009-03-11 21:05:02

Is the following code supposed to work (instead of resulting on a stack
overflow)? If so, what I'm doing wrong? I'm using Boost 1.37.0 on MS
Visual Studio 2008, Windows.

#include <boost/thread/once.hpp>

boost::once_flag initialization_flag = BOOST_ONCE_INIT;

void call_me_once()
        boost::call_once( initialization_flag, call_me_once );

int main( int, char*[] )
        boost::call_once( initialization_flag, call_me_once );

        return 0;


- Can a once_flag be safelly used in a class or local static?
- Is BOOST_ONCE_INIT guaranteed to statically initialize the flag?

Agustín K-ballo Bergé.-

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at