Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-01-16 18:01:42


Pavel Vozenilek wrote:

>It is wrong IMHO because:
>1. The Type needs default constructor
>
>
This is a singleton allocator... because singletons manage their own
lifetime, aren't default ctors the only kind that make sense?

>2. The Type instance gets always created (and possibly
> recreated again)
>
>
I thought that it would only be created the first time control enters
the function.

>3. The first Typeinstance may be "destroyed" w/o
> calling destructor.
>
>
Except that where this class is used (by the singleton), calls to create
and destroy will always be matched...

>Alexandresu uses union aligned to fit anything
>with sizeof(Type)...
>
>
He also mentions that this is not technically portable according to the
standard. I'd prefer to avoid such things, which seem like hacks to me,
if at all possible.

-Jason


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