1. 程式人生 > >thread safe singleton in c++11

thread safe singleton in c++11

class CSingleton final { public :      static CSingleton& GetInstance();
private :      CSingleton() = default ;      ~CSingleton() = default ;       
CSingleton( const CSingleton&) = delete ;      CSingleton& operator=( const CSingleton&) = delete ;      CSingleton(CSingleton&&) = delete ;      CSingleton& operator=(CSingleton&&) =
delete ; };   CSingleton& CSingleton::GetInstance() {      static CSingleton instance;      return instance;

}

 轉載:點選開啟連結