#include #include #pragma once namespace ace { template class singleton { public: static T & get() { if (_singletonInstance == nullptr) { assert(_initialized == false); _initialized = true; _singletonInstance = new T(); } return *_singletonInstance; } static void release() { delete _singletonInstance; } protected: static T *_singletonInstance; static bool _initialized; }; template T* singleton::_singletonInstance = nullptr; template bool singleton::_initialized = false; }