#include // for std::once_flag (C++11) #include // for std::unique_ptr (C++11) class Single { static std::unique_ptr _inst; static std::once_flag public: static Single& Inst() { std::call_once(Single::_once, []() { _inst.reset(new Single()); }); return *_inst.get(); } }; std::once_flag - cppreference.com std:: once_flag C++ Concurrency support library Defined in header class once_flag ; (since C++11) The class std::once_flag is a helper structure for std::call_on...
원문 링크 : C++ 11 이상에서 Singleton 만들기