Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-11-14 11:47:30


> -----Original Message-----
> From: Peter Dimov [mailto:pdimov_at_[hidden]]
>
> From: <scleary_at_[hidden]>
> > 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
an
> > actual Singleton except as mentioned above.
>
> I have encountered the need to solve the init order problem many times. I
> automatically type
>
> std::list<win32::dialog*> & instances()
> {
> static std::list<win32::dialog*> i;
> return 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.

Yes, I think that would be the single greatest benefit to a generic
'singleton' template. IMO, it should act exactly like a local object with
static storage duration (meaning the user can force construction/destruction
order) but with the construction thread-safe.

        -Steve

P.S. I did think of another time I used singleton -- in a socket library,
for WinSock initialization. But in this case, just like before, I only had
to use it because I had to fit an ill-constructed API.


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