DP_S/include/Singleton.h

16 lines
365 B
C
Raw Permalink Normal View History

2022-09-01 16:56:37 +08:00
#ifndef __SINGLETON_H__
#define __SINGLETON_H__
//饿汉模式
#define SINGLETON_DEFINE_S(TypeName) \
static TypeName* Get() \
{ \
static TypeName type_instance; \
return &type_instance; \
} \
\
TypeName(const TypeName&) = delete; \
TypeName& operator=(const TypeName&) = delete
#endif // __SINGLETON_H__