Public Member Functions | Static Public Member Functions | List of all members
ecl::Singleton< T > Class Template Reference

Singleton construction via the curiously recurring template pattern. More...

#include <singleton.hpp>

Public Member Functions

virtual ~Singleton ()

Static Public Member Functions

static T & instance ()

Detailed Description

template<typename T>
class ecl::Singleton< T >

Singleton construction via the curiously recurring template pattern.

This class doesn't provide singletons, but enables the construction of referenced based singletons via the curiously recurring template pattern.

If you wish to create a singleton, simply:

#define Test TestObject::instance()
cout << Test.value() << endl;
See also
src/test/singleton.cpp, Singletons

Definition at line 51 of file singleton.hpp.

Constructor & Destructor Documentation

template<typename T >
virtual ecl::Singleton< T >::~Singleton ( )

Definition at line 65 of file singleton.hpp.

Member Function Documentation

template<typename T >
static T& ecl::Singleton< T >::instance ( )

Stores a reference to a single instantiation of the template object. If the template class has a protected or private default constructor (no arguments), then it ensures the class will be a singleton itself.

Definition at line 59 of file singleton.hpp.

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

Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:29