GMP 0.3.0
Generative Metaprogramming library for C++
Loading...
Searching...
No Matches
gmp::singleton< T, true > Class Template Reference

Singleton specialization with dead-reference recovery support. More...

#include <singleton.hpp>

Static Public Member Functions

template<typename... Args>
static T & instance (Args &&... args)
 Get the singleton instance, recreating it if necessary.
 

Protected Member Functions

 singleton ()=default
 
virtual ~singleton ()
 

Static Protected Attributes

static T * pInstance_
 
static bool destroyed_
 

Detailed Description

template<typename T>
class gmp::singleton< T, true >

This specialization keeps explicit state about the singleton lifetime and can recreate the singleton if instance() is called after destruction.

Template Parameters
TThe derived singleton type.

Definition at line 101 of file singleton.hpp.

Constructor & Destructor Documentation

◆ singleton()

template<typename T >
gmp::singleton< T, true >::singleton ( )
protecteddefault

◆ ~singleton()

template<typename T >
virtual gmp::singleton< T, true >::~singleton ( )
inlineprotectedvirtual

Definition at line 152 of file singleton.hpp.

Member Function Documentation

◆ instance()

template<typename T >
template<typename... Args>
static T & gmp::singleton< T, true >::instance ( Args &&...  args)
inlinestatic
Template Parameters
ArgsConstructor argument types.
Parameters
argsConstructor arguments used during creation or recreation.
Returns
A reference to the singleton instance.

Definition at line 110 of file singleton.hpp.

References gmp::enum_values().


The documentation for this class was generated from the following file: