2022-9-2 01:27:03
This commit is contained in:
15
include/Singleton.h
Normal file
15
include/Singleton.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#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__
|
||||
Reference in New Issue
Block a user