|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-08-28 10:50:48
----- Original Message -----
From: Peter Dimov <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, August 28, 2001 12:11 PM
Subject: Re: [boost] Proposal: statefull objects
> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> > (At least, let me know if the trick I used to remove the requirement of
> > default-constructible is appropriate)
>
> Unfortunately not, it ignores T's alignment requirements AFAICS.
>
This is what I was worry about, precisely. Thanks for looking at it.
But I'am confused then...
It is guaranteed that if the array of chars is allocated with new[] it has
the appropriate aligment, but, from what you say, it appears that this is
not the case when the array has automatic storage. Is that so?
Hmm. Seems that you are right, pity! I've realized that allocator<> works
because it always uses malloc(), so the guarantee is fulfilled. (of course!
If optional<T> is created in the stack there's no way to align 'storage'
properly!)
Well, I think that optional<> is still usefull even if T is required to have
a default constructor, but then it is not as nice as I thougth.
(but I'll keep finding a way remove that requirement without allocating in
the heap).
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk