nlib
nn::nlib::Singleton< T > Class Template Referencefinal

Singleton initialized by the object when first used. More...

#include "nn/nlib/Singleton.h"

Static Public Member Functions

static T & Instance ()
 Gets the singleton instance of T. More...
 

Detailed Description

template<class T>
class nn::nlib::Singleton< T >

Singleton initialized by the object when first used.

Template Parameters
TThe singleton target class.
Description
The memory for the singleton object is aligned to 8 bytes and statically allocated ahead of time. The singleton is initialized by the constructor when the Instance function is called the first time.
Initialization is performed only once in a thread-safe manner, and the call to the constructor is certain to end when control returns from the Instance function.
Note the following.
  • The default constructor must be defined in the T class.
  • No call is made to the T class destructor.
// Gets a singleton object.

Definition at line 11 of file Singleton.h.

Member Function Documentation

§ Instance()

template<class T >
nn::nlib::Singleton< T >::Instance ( )
inlinestatic

Gets the singleton instance of T.

Returns
The reference to the instance of T.

Definition at line 13 of file Singleton.h.


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