-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathalignof.cpp
More file actions
27 lines (23 loc) · 840 Bytes
/
alignof.cpp
File metadata and controls
27 lines (23 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
struct Foo {
int i;
float f;
char c;
};
struct Empty {};
struct alignas(64) Empty64 {};
int main()
{
std::cout << "Alignment of" "\n"
"- char : " << alignof(char) << "\n"
"- char size of : " << sizeof(char) << "\n"
"- int : " << sizeof(int) << "\n"
"- float : " << sizeof(float) << "\n"
"- pointer : " << alignof(int*) << "\n"
"- pointer size of : " << sizeof(int*) << "\n"
"- class Foo : " << alignof(Foo) << "\n"
"- class Foo size of: " << sizeof(Foo) << "\n"
"- empty class : " << alignof(Empty) << "\n"
"- empty class size : " << sizeof(Empty) << "\n"
"- alignas(64) Empty: " << alignof(Empty64) << "\n";
}