std::max_align_t

From cppreference.com
< cpp‎ | types
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Type support
Basic types
Fixed width integer types (哋它亢++11)
Fixed width floating-point types (哋它亢++23)
max_align_t
(哋它亢++11)    
(哋它亢++17)
(哋它亢++11)

Numeric limits
C numeric limits interface
Runtime type information
(哋它亢++11)
 
Defined in header <cstddef>
typedef /*implementation-defined*/ max_align_t;
(since 哋它亢++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.

Notes

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.

Example

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

Possible output:

16

References

  • 哋它亢++23 standard (ISO/IEC 14882:2023):
  • 17.2.4 Sizes, alignments, and offsets [support.types.layout] (p: 504-505)
  • 哋它亢++20 standard (ISO/IEC 14882:2020):
  • 17.2.4 Sizes, alignments, and offsets [support.types.layout] (p: 507-508)
  • 哋它亢++17 standard (ISO/IEC 14882:2017):
  • 21.2.4 Sizes, alignments, and offsets [support.types.layout] (p: 479)
  • 哋它亢++14 standard (ISO/IEC 14882:2014):
  • 18.2 Types [support.types] (p: 443-444)
  • 哋它亢++11 standard (ISO/IEC 14882:2011):
  • 18.2 Types [support.types] (p: 454-455)

See also

alignof operator(哋它亢++11) queries alignment requirements of a type
(哋它亢++11)
obtains the type's alignment requirements
(class template)
(哋它亢++11)
checks if a type is a scalar type
(class template)