I’m working with some code I borrowed from here which uses boost::call_once to make a singleton class, and would like to convert everything to use C++0x’s std::call_once to remove the dependency on Boost. Does anyone know what the Std equivalent of BOOST_ONCE_INIT is?
I’m working with some code I borrowed from here which uses boost::call_once to make
Share
std::once_flaghas aconstexprconstructor, so instances with static storage duration are always statically initialized.Incidentally, the point about
scoped_ptris important — the constructor of thescoped_ptrinstance is NOT static initialization, so will race with any uses of the singleton before it has been initialized, and possibly overwrite the pointer.