QuantLib: Singleton< T > Class Template Reference

A free/open-source library for quantitative finance Reference manual - version 1.12

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

Basic support for the singleton pattern. More...

`#include <ql/patterns/singleton.hpp>`

Inherits noncopyable.

## Static Public Member Functions
static T & | instance ()
| access to the unique instance

## Detailed Description

### template<class T>
class QuantLib::Singleton< T >

Basic support for the singleton pattern.

The typical use of this class is:

class Foo : public Singleton<Foo> {
friend class Singleton<Foo>;
private:
Foo() {}
public:
...
};

which, albeit sub-optimal, frees one from the concerns of creating and managing the unique instance and can serve later as a single implemementation point should synchronization features be added.