Last active
March 28, 2016 07:38
-
-
Save ar1a/735e2961ffc6796710da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SINGLETON_H | |
#define SINGLETON_H | |
template<class T> | |
class singleton | |
{ | |
public: | |
static T* instance() | |
{ | |
return m_instance ? m_instance : (m_instance = new T); | |
} | |
protected: | |
singleton(); | |
~singleton(); | |
private: | |
singleton(singleton const&); | |
singleton& operator=(singleton const&); | |
static T* m_instance; | |
}; | |
template <class T> T* singleton<T>::m_instance = nullptr; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment