CppCommon 1.0.5.0
C++ Common Library
Loading...
Searching...
No Matches
singleton.h
Go to the documentation of this file.
1
9#ifndef CPPCOMMON_UTILITY_SINGLETON_H
10#define CPPCOMMON_UTILITY_SINGLETON_H
11
12namespace CppCommon {
13
15
45template <typename T>
47{
48 friend T;
49
50public:
51 Singleton(const Singleton&) = delete;
52 Singleton(Singleton&&) = delete;
53
54 Singleton& operator=(const Singleton&) = delete;
56
58
61 static T& GetInstance()
62 {
63 static T instance;
64 return instance;
65 }
66
67private:
68 Singleton() noexcept = default;
69 ~Singleton() noexcept = default;
70};
71
74} // namespace CppCommon
75
76#endif // CPPCOMMON_UTILITY_SINGLETON_H
Singleton template base class.
Definition singleton.h:47
Singleton & operator=(Singleton &&)=delete
Singleton(const Singleton &)=delete
Singleton & operator=(const Singleton &)=delete
static T & GetInstance()
Get singleton instance.
Definition singleton.h:61
Singleton(Singleton &&)=delete
C++ Common project definitions.