Suppose I have a templated function that deals with pointers to an as yet unknown type T
Now, if type T
turns out to be void*
on a 64-bit platform, then it must be aligned with 8 bytes, but if T
turns out to be char
, it must be aligned by 1 byte, and if T
happens to be a class, then its alignment requirements will depend on its member variables.
All this can be calculated on paper, but how to get the compiler to fulfill the alignment requirements for a given type T
?
Is there a way to find at compile time alignment requirements for a given type?
source share