
11-04-2010, 02:32
|
 |
|
|
חבר מתאריך: 14.12.09
הודעות: 9,751
|
|
אז זהו, שלא...
§9.2.17
A pointer to a POD-struct object, suitably converted using a reinterpret_cast, points to its initial
member (or if that member is a bit-field, then to the unit in which it resides) and vice versa. [Note: There
might therefore be unnamed padding within a POD-struct object, but not at its beginning, as necessary to
achieve appropriate alignment. ]
§9.2.12
Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated
so that later members have higher addresses within a class object. The order of allocation of nonstatic
data members separated by an access-specifier is unspecified (11.1). Implementation alignment requirements
might cause two adjacent members not to be allocated immediately after each other; so might
requirements for space for managing virtual functions (10.3) and virtual base classes (10.1).
באופן מעניין, למערכים מובטח שהגודל של מערך של N אלמנטים מטיפוס T יהיה בגודל של N כפול sizeof(T). המשמעות של זה היא שפנייה לאלמנטים שונים של מערך יכולה לקחת זמן שונה, בתלות ב-alignment.
ושוב, אני ממליץ להשיג עותק על התקן. מגלים שם דברים מעניינים.
|