1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#ifndef __UTIL_SINGLETON_H #define __UTIL_SINGLETON_H template <typename _T> class Singleton : private _T { public: static _T& instance() { static Singleton<_T> instance; return instance; }; private: Singleton() : _T() {}; }; #endif