92 lines
1.9 KiB
C++
92 lines
1.9 KiB
C++
/*
|
|
VIM: let b:cf5build="clang -std=c++20 -O2 -pthread -lstdc++ -I. {SRC} -o {OUT}"
|
|
VIM: let b:cf5run="{OUT}"
|
|
*/
|
|
#include <iostream>
|
|
#include <exception>
|
|
#include <chrono>
|
|
|
|
struct A {
|
|
long l;
|
|
char c;
|
|
};
|
|
|
|
struct L {
|
|
long l;
|
|
};
|
|
|
|
struct C {
|
|
char c;
|
|
};
|
|
|
|
struct B {
|
|
bool b;
|
|
};
|
|
|
|
struct alignas(16) Ba {
|
|
bool b;
|
|
};
|
|
|
|
struct alignas(16) BBa {
|
|
bool b;
|
|
bool b2;
|
|
};
|
|
|
|
struct alignas(16) BBaa {
|
|
alignas(16) bool b;
|
|
alignas(16) bool b2;
|
|
};
|
|
|
|
struct I128 {
|
|
__int128 i128;
|
|
};
|
|
|
|
struct I128i {
|
|
__int128 i128;
|
|
int i;
|
|
};
|
|
|
|
int main ( void )
|
|
{try{
|
|
auto begin = std::chrono::high_resolution_clock::now();
|
|
|
|
A a;
|
|
L l;
|
|
C c;
|
|
B b;
|
|
Ba ba;
|
|
BBa bba;
|
|
BBaa bbaa;
|
|
I128 i128;
|
|
I128i i128i;
|
|
|
|
std::cout << "sizeof(A)=" << sizeof(A) << " &a=" << &a <<std::endl;
|
|
std::cout << "sizeof(L)=" << sizeof(L) << " &l=" << &l <<std::endl;
|
|
std::cout << "sizeof(C)=" << sizeof(C) << " &c=" << &c <<std::endl;
|
|
std::cout << "sizeof(B)=" << sizeof(B) << " &b=" << &b <<std::endl;
|
|
std::cout << "sizeof(Ba)=" << sizeof(Ba) << " &ba=" << &ba <<std::endl;
|
|
std::cout << "sizeof(BBa)=" << sizeof(BBa) << " &bba=" << &bba <<std::endl;
|
|
std::cout << "sizeof(BBaa)=" << sizeof(BBaa) << " &bbaa=" << &bbaa <<std::endl;
|
|
std::cout << "sizeof(I128)=" << sizeof(I128) << " &i128=" << &i128 <<std::endl;
|
|
std::cout << "sizeof(I128i)=" << sizeof(I128i) << " &i128i=" << &i128i <<std::endl;
|
|
//......
|
|
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<double> seconds = end - begin;
|
|
std::cout << "Time: " << seconds.count() << std::endl;
|
|
return 0;
|
|
}
|
|
catch ( const std::exception& e )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
|
return 2;
|
|
}
|
|
catch ( ... )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "unknown exception." << std::endl;
|
|
return 1;
|
|
}}
|
|
|