|
Boost : |
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
> address?
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
0x8000 character
0x8001 padding
0x8002 padding
0x8003 padding
0x8004 padding
0x8005 padding
0x8006 padding
0x8007 padding
0x8008 integer
0x800A integer
0x800B integer
0x800C integer
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