-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern.singeton.h
38 lines (31 loc) · 967 Bytes
/
pattern.singeton.h
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
/* *****************************************
* File: pattern.singeton.h
* Purpose: Portable (cross-platform), light-weight functions
* *****************************************
* Library: Cross Platform C++ Classes (cpcc)
* Copyright: StarMessage software.
* License: Free for opensource projects.
* Commercial license exists for closed source projects.
* Web: http://www.StarMessageSoftware.com/cpcclibrary
* Download: https://github.com/starmessage/cpcc
* email: sales -at- starmessage.info
* *****************************************
*/
#pragma once
// template <typename T, T aDefault>
template <typename T>
class cSingleton
{
public:
static T& getInstance()
{
static T theinstance{} /* = aDefault */;
return theinstance;
}
protected:
cSingleton() {}
~cSingleton() {}
private:
cSingleton(cSingleton const&);
void operator=(cSingleton const&);
};