-
Steffen Müthing authored
DestructibleSingletonHolder is a little utility that helps in building singletons that can be created and destroyed multiple times during the lifetime of a program. The class holds a unique_ptr to the actual singleton implementation and an instance of a factory for allocating that unique_ptr and initializing the singleton. The class is accompanied by a function template that stores an instance of the class in a static variable, which provides for the singleton. This function must always be called with the factory function, as it is templated on it. This makes it possible to keep the singleton private to a class by using a private static member function as the factory.
2d6c17dd