thread safe singleton in c++11
阿新 • • 發佈:2018-12-22
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;
}
轉載:點選開啟連結