C++:Google base中的方法

/ C++ / 没有评论 / 1543浏览

让一个类成为单例

namespace nbase
{

#define SINGLETON_DEFINE(TypeName)				\
static TypeName* GetInstance()					\
{												\
	static TypeName type_instance;				\
	return &type_instance;						\
}												\
												\
TypeName(const TypeName&) = delete;				\
TypeName& operator=(const TypeName&) = delete

}