Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-01 10:53:41


----- Original Message -----
From: "Douglas Gregor" <gregod_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, March 01, 2002 10:37 AM
Subject: Re: [boost] Re: New version of valunion and stack_allocator
uploaded

> On Friday 01 March 2002 10:28 am, you wrote:
> > Nice. Shouldn't we also be checking that the alignment of T is <= align,
> > just to be sure?
> >
> > -Dave
>
> Brian Parker's version has this note in it:
> (Note that ISO C++ guarantees that a type cannot have an alignment >
than
> its size as it needs to be able to be packed into arrays without padding
> between elements).
>
> Which would say that the additional check isn't needed. But it doesn't
hurt,
> so we might as well add it.

If it's redundant it costs compilation time.

I guess what I meant was that it probably makes more sense to check for
aligmnent_of<T> <= align in place of sizeof<T> <= align. If you want to
ensure the right number of bytes, stick an array of char in the union like I
did.

-Dave


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