std::max_align_t(3)
okay so bestie, welcome to std::max_align_t(3) from the C++ Standard Libary manual β itβs giving tiny-but-mighty C++ energy πβ¨
π NAME π
std::max_align_tβstd::max_align_t
yes, the name is literally the name. we respect it π
πΈ Synopsis πΈ
Defined in header <cstddef>
typedef /*implementation-defined*/ max_align_t; (since C++11)
okay so the actual tea: 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. periodt β¨
π¦ 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. so if youβre allocating, youβre covered, no cap π₯
π Example π
// Run this code
#include <cstddef>
#include <iostream>
int main()
{
std::cout << alignof(std::max_align_t) << '\n';
}
π Possible output π
16
β¨ References β¨
- C++23 standard (
ISO/IEC 14882:2023):17.2.4 Sizes, alignments, and offsets [support.types.layout](p: 504-505)
- C++20 standard (
ISO/IEC 14882:2020):17.2.4 Sizes, alignments, and offsets [support.types.layout](p: 507-508)
- C++17 standard (
ISO/IEC 14882:2017):21.2.4 Sizes, alignments, and offsets [support.types.layout](p: 479)
- C++14 standard (
ISO/IEC 14882:2014):18.2 Types [support.types](p: 443-444)
- C++11 standard (
ISO/IEC 14882:2011):18.2 Types [support.types](p: 454-455)
π See also π
alignofoperator(C++11) β queries alignment requirements of a typealignment_of(C++11) β obtains the typeβs alignment requirements (class template)is_scalar(C++11) β checks if a type is a scalar type (class template)- C documentation for
max_align_t
source: http://cppreference.com Β· dated 2024.06.10 Β· page: std::max_align_t(3) β bye bestie, go check your alignments ππ¦
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms