10 static T &instance() {
13 throw std::runtime_error(
"already deallocated!");
26 static void init() { s_pInstance = std::shared_ptr<T>(
new T()); }
27 static void dealloc() { s_pInstance.reset(); }
30 static std::shared_ptr<T> s_pInstance;
31 static std::once_flag s_init_once;
32 static std::once_flag s_dealloc_once;