For any type T
is it always the case that sizeof(T)
is at least as large as alignof(T)
?
Intuitively it seems so, since even when you adjust the alignment of objects like:
struct small {
char c;
};
that would normally be small, their "size" is also adjusted upwards so that the relationship between objects in an array makes sense while maintaining alignment. For example:
struct alignas(16) small16 {
char c;
};
Has both a size and alignment of 16.
Aucun commentaire:
Enregistrer un commentaire