C++ <cstddef> - max_align_t Type
The C++ <cstddef> max_align_t is a type whose alignment requirement is at strict (as large) as that of any possible scalar type, and whose alignment requirement is supported in every context.
max_align_t is usually synonymous with the largest scalar type, which is long double on most platforms, and its alignment requirement is either 8 or 16.
Pointers returned by allocation functions such as malloc() are suitably aligned for any object, which means they are aligned at least as strictly as max_align_t.
In the <cstddef> header file, it is defined as follows:
typedef /* implementation-defined */ max_align_t;
Example:
In the example below shows how to get the alignment requirement of a given platform.
#include <iostream> #include <cstddef> using namespace std; int main() { size_t x = alignof(max_align_t); cout<<"Alignment of max_align_t is: "<<x; return 0; }
The output of the above code will be:
Alignment of max_align_t is: 16
❮ C++ <cstddef> Library