#include <Pt/Singleton.h>
Singleton class template More...
Inherits NonCopyable.
Static Public Member Functions | |
static T & | instance () |
Returns the instance of the singleton type. More... | |
Protected Member Functions | |
Singleton () | |
Constructor. | |
~Singleton () | |
Destructor. | |
T | Type of the singleton |
A | Allocator for type T |
The Singleton class template can be used to easily implement the Singleton design pattern. It can either be used directly or as a base class.
The follwing example shows how to use the singleton as a base class:
|
static |
When called for the first time, the singleton instance will be created with the specified alloctaor. All subsequent calls will return a reference to the previously created instance.