标签:
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;
标签:
原文地址:http://www.cnblogs.com/kaishan1990/p/5134004.html