Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-08-27 05:52:16


>1. since padded has a user-defined ctor, it is non-POD, and the compiler
>free to lay it out any way it likes. For example, the definition of T
>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

>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.

- John

Boost list run by bdawes at, gregod at, cpdaniel at, john at