template <typename T> class Singleton { public: template <typename... Args> static T* Instance(Args&&... args) { if ( m_pInstance == NULL ) { m_pInstance = new T(std::forward<Args>(args)...); } return m_pInstance; } static T * GetInstance() { if ( m_pInstance == NULL ) { } return m_pInstance; } static void DestoryInstance() { delete m_pInstance; m_pInstance = NULL; } private: Singleton(); virtual ~Singleton(); Singleton(const Singleton&); Singleton& operator = (const Singleton &); static T *m_pInstance; };
template <typename T> T* Singleton<T>::m_pInstance = NULL;