I work with shared memory right now.
I can\'t understand alignof
and alignas
.
cppreference is unclear : alignof
return
Each type has an alignment requirement. Generally, this is so variables of the type can be accessed efficiently, without having to cause the CPU to generate more than one read/write access in order to reach any given member of the datatype. Furthermore, it also ensure efficient copying of the entire variable. alignof
will return the alignment requirement for the given type.
alignas
is used to force an alignment on a datatype (so long as it is not less stringent that what alignof
said datatype would return)