C++单例
程序员文章站
2022-07-09 22:14:06
1 template
2 class Singleton
3 {
4 public:
5 using object_type = T;
6 struct object...
1 template
2 class Singleton
3 {
4 public:
5 using object_type = T;
6 struct object_creator
7 {
8 object_creator()
9 {
10 Singleton
11 }
12 };
13
14 static object_creator creator_object;
15 public:
16 static object_type* instance()
17 {
18 static object_type _instance;
19 return(&_instance);
20 }
21 };
22 template