From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-11-14 09:16:03
> Like you, I'm more inclined to just declare global resources as normal
> objects, and just create instances of them in main(). I have never used
> actual Singleton except as mentioned above.
I have encountered the need to solve the init order problem many times. I
std::list<win32::dialog*> & instances()
static std::list<win32::dialog*> i;
> So, maybe we don't need one after all?
_I_ don't need one provided that I can (easily) make the above thread safe.
This is not yet covered by Boost to the extent that I'd have liked.
But if we move from technical to psychological reasons, many developers
think that a design pattern that has such a cool name absolutely needs to
have an associated class (template.) The next trap they fall into, of
course, is in thinking that making a global variable a 'Singleton' somehow
makes it less global and hence, acceptable. ;-)
BTW I agree with your analysis on singleton policies. A singleton - C++
sense - is an object that logically always exists for the duration of the
program. It's as if it had been constructed at compile time and is never
destroyed, always ready to be used.
Adding 'policies' simply means that the object is no longer a singleton, but
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk