|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2000-08-27 09:16:20
----- Original Message -----
From: "John Maddock" <John_Maddock_at_[hidden]>
> >1. since padded has a user-defined ctor, it is non-POD, and the compiler
> is
> >free to lay it out any way it likes. For example, the definition of T
> might
> >be:
> >
> >struct T { int x; char c; };
> >
> >If the compiler laid out padded::c right after T::c, alignment would be
0.
> >What does it mean to have 0 alignment?
>
> No that can't happen: see 9.2.12
I see that you're quite right.
> >2. A compiler which just has a policy of aligning all structs on 4-byte
> >boundaries (I've seen that) will produce the answer 3 when T is char.
>
> Point taken - the only guarantee that alignment_of makes is that it
returns
> a multiple of the actual alignment, in this case I accept that maybe we
can
> do better in the case that T is a POD, I guess maybe a specialisation for
> the case that "is_POD<T>::value" is true would help here. On balance
> though I prefer alignment_of to work with non-POD types (as it does now)
> than restrict it to POD's alone.
I agree. Good work! I'll start using your jobby (a local Boston expression)
instead!
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk