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
5
namespace
myproject
{
6
7
template
<
typename
T,
typename
D = T>
8
class
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
;
18
Singleton
&
operator=
(
Singleton
&&) =
delete
;
19
static
T&
instance
();
20
};
21
22
template
<
typename
T,
typename
D>
23
T&
Singleton<T, D>::instance
() {
24
static
D inst;
25
return
inst;
26
}
27
28
}
// namespace myproject
myproject::Singleton
Definition
singleton.h:8
myproject::Singleton::~Singleton
~Singleton()=default
myproject::Singleton::Singleton
Singleton()=default
myproject::Singleton::Singleton
Singleton(Singleton &&)=delete
myproject::Singleton::operator=
Singleton & operator=(const Singleton &)=delete
myproject::Singleton::Singleton
Singleton(const Singleton &)=delete
myproject::Singleton::instance
static T & instance()
Definition
singleton.h:23
myproject::Singleton::operator=
Singleton & operator=(Singleton &&)=delete
myproject
Definition
application.cpp:63
src
core
singleton.h
Generated by
1.11.0