Boost logo

Boost :

Subject: [boost] Is there interest in an alternative to the Singleton anti-pattern?
From: Ben Robinson (icaretaker_at_[hidden])
Date: 2011-06-23 02:08:04

The Singleton pattern does have its uses because it guarantees a single
instance of a class. However, it suffers from three weaknesses:

1) Encapsulation: Singleton provides global access to the class. Some may
view this as a feature, but advocates of unit testing, and dependency
injection would disagree.
2) Initialization: Singleton restricts the class to the default constructor.
 This makes Singleton unusable for classes which require non-default
3) Lifetime: Singleton introduces lifetime management complexities (for a
detailed discussion, see Chapter 6 of Modern C++ Design by Andrei *

I have formalized what I believe is a novel design pattern, which guarantees
a single instance of a class, but which does not suffer 1-3 above. And
unlike Monostate, this pattern I propose does instantiate a genuine instance
of any class, using any one of its available constructors. I hope this
inquiry peaks your interest.

Thank you,

Ben Robinson, Ph.D.

Boost list run by bdawes at, gregod at, cpdaniel at, john at