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

Default singleton specialization using a function-local static object. More...

#include <singleton.hpp>

Static Public Member Functions

template<typename... Args>
static T & instance (Args &&... args)
 Get the singleton instance.
 

Protected Member Functions

 singleton ()=default
 
virtual ~singleton ()
 

Detailed Description

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

This specialization is the usual zero-overhead singleton form. The first call to instance() constructs the object, and subsequent calls return the same instance for the lifetime of the program.

Template Parameters
TThe derived singleton type.

Definition at line 65 of file singleton.hpp.

Constructor & Destructor Documentation

◆ singleton()

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

◆ ~singleton()

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

Definition at line 84 of file singleton.hpp.

Member Function Documentation

◆ instance()

template<typename T >
template<typename... Args>
static T & gmp::singleton< T, false >::instance ( Args &&...  args)
inlinestatic

The first call constructs the object using the provided arguments. Later calls ignore constructor arguments and return the same instance.

Template Parameters
ArgsConstructor argument types.
Parameters
argsConstructor arguments used on first initialization.
Returns
A reference to the singleton instance.

Definition at line 77 of file singleton.hpp.

References gmp::enum_values().


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