std::max_align_t (3) - Linux Manuals

std::max_align_t: std::max_align_t


std::max_align_t - std::max_align_t


Defined in header <cstddef>
typedef /*implementation-defined*/ max_align_t; (since C++11)

std::max_align_t is a trivial standard-layout type whose alignment_requirement is at least as strict (as large) as that of every scalar type.


Pointers returned by allocation functions such as std::malloc are suitably aligned for any object, which means they are aligned at least as strictly as std::max_align_t.
std::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.


// Run this code

  #include <iostream>
  #include <cstddef>
  int main()
      std::cout << alignof(std::max_align_t) << '\n';

Possible output:


See also

alignof_operator queries alignment requirements of a type (since C++11)

alignment_of obtains the type's alignment requirements
                 (class template)

is_scalar checks if a type is a scalar type
                 (class template)