Код: Выделить всё
struct A {
int64_t x; // 8 bytes
int32_t y; // 4 bytes
// 4 padding bytes
};
struct B {
A a; // 16 bytes
int32_t z; // 4 bytes
// 4 padding bytes (alignof(B) == alignof(A) == 8)
};
Код: Выделить всё
static_assert(sizeof(B) == 24); // 8 useless bytes!
Подробнее здесь: https://stackoverflow.com/questions/784 ... es-tightly
Мобильная версия