myproject 0.0.0
%%description%%
Loading...
Searching...
No Matches
singleton.h
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4
5namespace myproject {
6
7template <typename T, typename D = T>
8class Singleton {
9 friend D;
10 static_assert(std::is_base_of_v<T, D>, "T should be a base type for D");
11
12 public:
13 Singleton() = default;
14 ~Singleton() = default;
15 Singleton(const Singleton&) = delete;
16 Singleton(Singleton&&) = delete;
17 Singleton& operator=(const Singleton&) = delete;
19 static T& instance();
20};
21
22template <typename T, typename D>
24 static D inst;
25 return inst;
26}
27
28} // namespace myproject
Definition singleton.h:8
Singleton(Singleton &&)=delete
Singleton & operator=(const Singleton &)=delete
Singleton(const Singleton &)=delete
static T & instance()
Definition singleton.h:23
Singleton & operator=(Singleton &&)=delete
Definition application.cpp:63