Skip to content

Instantly share code, notes, and snippets.

@xiangzhuyuan
Forked from vinipsmaker/singleton.hpp
Created October 5, 2013 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiangzhuyuan/6840743 to your computer and use it in GitHub Desktop.
Save xiangzhuyuan/6840743 to your computer and use it in GitHub Desktop.
template<typename T>
class Singleton
{
public:
static T &instance()
{
if (!instance)
instance_ = new T;
return *instance_;
}
private:
static T *instance_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment