From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2003-02-11 10:07:30
David Abrahams wrote:
> Even if what you wrote made sense, which I'm not sure it does,
> [to me at least - how can a word boundary be a number (max over
> all types T of alignment_of<T> - sizeof(char)), rather than an
It is the result of arithmetics between sizeof(char)s, which is of type
size_t. It can be converted back to a char *.
> And then why subtract sizeof(char), i.e. 1, from the
> maximal alignment?]
> that algorithm relies on a big non-portable assumption, doesn't it?
Yes, but simple examples are faster to understand.
> Even if you enumerated all non-class types, there's no reason to think
> that the maximal alignment has any relationship to a machine word.
No exactly, but it will be a factor of the word boundary (wb = 4,
data_alignment = 8; 2 * 4 = 8).
Example is more consistant here:
- The processor aligns each character to 8 bits.
- The processor aligns each integer to 32 bits.
- BOOT_DATA_ALIGNMENT is set to 8
In this case: padding_of<char> will be equal to 7.
Philippe A. Bouchard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk