![]() |
POD data type with a fixed alignment.The AlignedStorage class template represents a POD data type with a fixed alignment. Via this class it is possible to enforce a specific, type-based alignment for static data types. The required alignment is evaluated based on the given data type T. In case T is a built-in, vectorizable data type, AlignedStorage enforces an alignment of 16 or 32 bytes, depending on the active SSE/AVX level. In all other cases, no specific alignment is enforced. More...
#include <AlignedStorage.h>
Inherits AlignedStorageHelper< AlignmentTrait< T >::value >.
POD data type with a fixed alignment.
The AlignedStorage class template represents a POD data type with a fixed alignment. Via this class it is possible to enforce a specific, type-based alignment for static data types. The required alignment is evaluated based on the given data type T. In case T is a built-in, vectorizable data type, AlignedStorage enforces an alignment of 16 or 32 bytes, depending on the active SSE/AVX level. In all other cases, no specific alignment is enforced.
In the following code example, the StaticVector class, representing a vector of N statically allocated elements, is non-publicly deriving from the AlignedStorage class template. By this, the N data elements of type T are aligned according to the requirements of T.
Note that since the AlignedStorage class template is designed as a base class proper alignment is heavily depending on the compiler's memory model for base classes (which influences how the base class's alignment restrictions are transfered to the deriving class) and it's capacity to perform an empty base class optimization (EBO). Currently, this approach works with the GCC, the Intel, and the Visual Studio compiler, but fails with the Clang compiler.