
[Mathias Gaunard]
which is simple, short, fast to compile, and thread-safe.
[John Maddock]
Not thread safe on the majority of compilers surely?
[Mathias Gaunard]
Isn't MSVC the only one that doesn't do it? And MSVC11 does it, I believe. I thought I had read that somewhere, but I can't find the source anymore so maybe I'm just confusing it with something else. Hopefully it will be the case though.
You're thinking of C++11 "magic statics" (my term), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm "Dynamic Initialization and Destruction with Concurrency". Neither VC10 nor GCC 4.6 implement magic statics (see http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-feature... and http://gcc.gnu.org/gcc-4.6/cxx0x_status.html ). I've heard (but don't take my word for it) that GCC currently ensures correctness here by taking a lock, which is far less desirable than the novel magic statics algorithm. VC does not ensure correctness here. We haven't yet revealed VC11's Core Language features, except for the bugfix-level ones that I've mentioned in passing (e.g. lambdas v1.1). Stephan T. Lavavej Visual C++ Libraries Developer