mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
21
code/9/9.3.alignment.cpp
Normal file
21
code/9/9.3.alignment.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
struct Storage {
|
||||
char a;
|
||||
int b;
|
||||
double c;
|
||||
long long d;
|
||||
};
|
||||
|
||||
struct alignas(std::max_align_t) AlignasStorage {
|
||||
char a;
|
||||
int b;
|
||||
double c;
|
||||
long long d;
|
||||
};
|
||||
|
||||
int main() {
|
||||
std::cout << alignof(Storage) << std::endl;
|
||||
std::cout << alignof(AlignasStorage) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user