Boost logo

Boost :

From: Andreas Huber (ahd6974-spamgroupstrap_at_[hidden])
Date: 2007-02-05 15:17:32

Fabien Niñoles wrote:
> Probably you should put it has a static local variable inside a
> protected function, like this:
> //! The method returns a reference to the only dispatcher instance
> static state_dispatcher const& get()
> {
> static state_dispatcher instance;
> return instance;
> }

In a multithreaded app this might work on some platforms, on others it

Quote from
"Assigning to a static local variable is not thread safe and is not
recommended as a programming practice."

Although this isn't very concise wording (IIRC, the standard says that
it should work for literals assigned to PODs) it seems clear that it
won't work for non-PODs...


Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

Boost list run by bdawes at, gregod at, cpdaniel at, john at