Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-09-26 08:32:41


> On pthreads, boost::once_init is defined like this:
>
> namespace boost
> {
> typedef pthread_once_t once_flag;
> const once_flag once_init = PTHREAD_ONCE_INIT;
> }
>
> Is it guaranteed that
>
> boost::once_flag x = boost::once_init;
>
> is statically initialized?

I had the same question this morning. I don't think so, because
pthread_once_t does not have to be an arithmetic type [POSIX Draft 7 Base
Definitions, line 12984]. It can be a POD, which would make
boost::once_init statically initialized, but ::x dynamically initialized,
from my reading of the C++ Standard. Providing:
  #define BOOST_ONCE_INIT PTHREAD_ONCE_INIT
would work around this.

        -Steve


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk