c++单例模式实现
class noncopyable
{
public:
noncopyable(const noncopyable&) = delete;
noncopyable& operator=(const noncopyable&) = delete;
noncopyable() = default;
~noncopyable() = default;
};
template <class ValueType>
class Singleton :public noncopyable
{
public:
static ValueType& GetInstance()
{
static ValueType t;
return t;
}
protected:
Singleton() = default;
~Singleton() = default;
};