::public/C++
(C++11) alignas
해맑은욱
2023. 1. 18. 10:15
alignas(n)
지정한 수의 배수만큼 구조체가 할당된다.(1 or 2 의 배수로 설정해야함)
struct alignas(32) Alignas
{
int i4; // 4 byte
char c[3]; // 3 byte
short s2; // 2 byte
};
Alignas al;
cout << sizeof(al) << endl; // 32 byte
https://en.cppreference.com/w/cpp/language/alignas
alignas specifier (since C++11) - cppreference.com
Specifies the alignment requirement of a type or an object. [edit] Syntax alignas( expression ) alignas( type-id ) alignas( pack ... ) 2) Equivalent to alignas(alignof(type-id)) 3) Equivalent to multiple alignas specifiers applied to the same declaration,
en.cppreference.com