Zth (libzth)
|
#include <util.h>
Public Types | |
typedef T | singleton_type |
Alias of the T template parameter. More... | |
Static Public Member Functions | |
constexpr static safe_ptr< singleton_type >::type | instance () noexcept |
Return the only instance of T . More... | |
Protected Member Functions | |
constexpr | Singleton () noexcept |
Constructor. More... | |
~Singleton () | |
Destructor. More... | |
Singleton pattern.
When a class inherits this class, the single instance of that class is available via the static instance() function.
A class should use Singleton as follows:
Make sure that the template parameter T
is the same as the subclass.
T | the type of the subclass that inherits this Singleton. |
typedef T zth::Singleton< T >::singleton_type |
|
inlineconstexprprotectednoexcept |
|
inlineprotected |
Destructor.
After destruction, instance() will return nullptr
.
|
inlinestaticconstexprnoexcept |