Boost logo

Boost :

From: Brian Gray (briangray_at_[hidden])
Date: 2003-03-04 13:17:51


On Tuesday, March 4, 2003, at 03:12 AM, Aashit Soni wrote:
> Do we have singleton class?
> if we dont have that and think to have it - i'd designed one simple
> _singleton<> that works good to make parameter class singleton..

I've done much work with singletons, and I've come around to the
opinion that they should not be implemented as wrappers. Singleton
status of a class should be designed in from the beginning and enforced
at the class level, otherwise it's all too common to use any old class
wrapped in a singleton holder as a global variable. I find myself
falling into that trap when I have a class for which I want only one
instance but there is no real reason why there couldn't be more. I
only need one so I use a singleton. If you enforce the choice at
design time by having it be an inheritable trait rather than a wrapper,
it's less likely to be used as a mere convenience, and more likely to
indicate a class for which there should conceptually be exactly one
instance.

  -- Brian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk