Nifty/Schwarz counter, standard compliant?
I had a discussion this morning with a colleague about static variable initialization order. He mentioned the Nifty/Schwarz counter and I'm (sort of) puzzled. I understand how it works, but I'm not sure if this is, technically speaking, standard compliant. Suppose the 3 following files (the first two are copy-pasta'd from More C++ Idioms ): //Stream.hpp class StreamInitializer; class Stream { friend class StreamInitializer; public: Stream () { // Constructor must be called before use. } }; static class StreamInitializer { public: StreamInitializer (); ~StreamInitializer (); } initializer; /