Re: Threadsafe singletons
"kanze" <kanze@gabi-soft.fr> schrieb im Newsbeitrag
news:1154513641.311594.134690@h48g2000cwc.googlegroups.com...
Strangely, I found no text in the standard that explicitly
guarantees that an object will be initialized before it is
first used... Or maybe I just overlooked it?
No. This guarantee is explicitly not given; there are even
cases where the standard guarantees that the dynamic
initialization will NOT have taken place before the object is
used. (My solution to this problem, with:
Singleton* Singleton::ourInstance = &Singleton::instance() ;
is an example of code which counts on the function seeing the
zero initialization, before the dynamic initialization has
terminated.)
You mean, you are checking for a null pointer whereever
Singleton::ourInstance is used?
--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]