Skip to content

Instantly share code, notes, and snippets.

@xaxxon
Created December 31, 2015 00:46
Show Gist options
  • Save xaxxon/f6eb8335686bd1047f49 to your computer and use it in GitHub Desktop.
Save xaxxon/f6eb8335686bd1047f49 to your computer and use it in GitHub Desktop.
template <class T>
class Singleton
{
public:
static T* Instance() {
if(!m_pInstance) m_pInstance = new T;
assert(m_pInstance != NULL);
return m_pInstance;
}
protected:
Singleton();
~Singleton();
private:
Singleton(Singleton const&);
Singleton& operator=(Singleton const&);
static T* m_pInstance;
};
template <class T> T* Singleton<T>::m_pInstance=NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment