-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmacrolib.cpp
65 lines (44 loc) · 1.15 KB
/
macrolib.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <cassert>
#include "macrolib.h"
// 使用方法演示
class __ASingletonClass : public Singleton<__ASingletonClass>
{
};
// 使用方法演示
class __BSingletonClass : public Singleton<__BSingletonClass>
{
};
// 使用方法演示
class __CSingletonClass : public Singleton<__CSingletonClass>
{
};
// 使用方法演示
class __DSingletonClass : public Singleton<__DSingletonClass>
{
public:
friend class Singleton;
private:
__DSingletonClass(int a, char b, const char *c)
{
}
__DSingletonClass()
{
}
void init(int a, char b, const char *c)
{
}
};
void __test_macrolib()
{
auto _ch = __ASingletonClass::inst_simple();
auto _ch2 = __BSingletonClass::inst_simple();
auto _ch3 = __CSingletonClass::inst_simple();
// _ch ==? _ch2 ==? _ch3
assert((void*)_ch != (void*)_ch2 && (void*)_ch2 != (void*)_ch3);
auto _vch = __ASingletonClass::inst();
auto _vch2 = __BSingletonClass::inst();
auto _vch3 = __CSingletonClass::inst();
const char *_cv = "cccccc";
auto _vch4 = __DSingletonClass::inst(5, 'b', (char*)NULL);
auto _vch5 = __DSingletonClass::inst(5, 'b', _cv);
}