Created
March 16, 2013 15:16
-
-
Save 0xa/5176833 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 COMMON_SINGLETON_H | |
#define COMMON_SINGLETON_H | |
#include <memory> | |
template<typename T> | |
class Singleton { | |
public: | |
static inline std::shared_ptr<T> GetInstancePtr() { | |
static std::shared_ptr<T> instance = new T(); | |
return instance; | |
} | |
static inline T& GetInstance() { | |
return *GetInstancePtr(); | |
} | |
private: | |
Singleton(); | |
Singleton(const Singleton<T> &); | |
Singleton& operator=(const Singleton<T> &); | |
}; | |
#endif // COMMON_SINGLETON_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment