首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::max_align_t

Defined in header <cstddef>

typedef /*implementation-defined*/ max_align_t;

(since C++11)

std::max_align_t是POD类型对齐要求至少有每种标量类型的严格%28和%29一样大。

注记

由分配函数返回的指针,如std::malloc对任何对象都适当地对齐,这意味着它们至少与std::max_align_t...

std::max_align_t通常是最大标量类型的同义词,它是long double在大多数平台上,其对齐的需求要么是8,要么是16。

二次

代码语言:javascript
复制
#include <iostream>
#include <cstddef>
int main()
{
    std::cout << alignof(std::max_align_t) << '\n';
}

二次

可能的产出:

二次

代码语言:javascript
复制
16

二次

另见

alignof operator

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

alignment_of (C++11)

obtains the type's alignment requirements (class template)

is_scalar (C++11)

checks if a type is scalar type (class template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券