
Thorsten Ottosen wrote:
1. have I misunderstood aligmnet completely when I thought that a single data member was not guaranteed to be aligned, but an array ways? (your aligned types use a data member, your unaligned use a char array).
Every variable is aligned according to its own alignment requirements. Typically, a variable needs to be aligned on a boundary of its own size, i.e. a byte type must be byte-aligned, a word type word-aligned and so on. An array is always aligned according to its underlying type. Thus, to get a simple aligned type, just use a member of that type. To get an unaligned type, you need to allocate storage that is byte-aligned, and the easiest way of doing this is using a char[sizeof(T)]. I hope that answers the question as well. Sebastian Redl