
#include <iostream>
using namespace std;
//两个指针相减,得到的是相隔几个元素
//char* 相隔几个元素,就是相隔几个字节
#define sizeof_v(x) (char*)(&x+1) - (char*)(&x)
#define sizeof_t(t) ((size_t)((t*)0 + 1))
//对齐,内存池中,内存块大小是规则的。产生空隙碎片
#define ALIGN(v,b) ((v+b-1) & ~(b-1))
class Empty {
};
int main(void ) {
Empty e;
int n;
cout << sizeof_v(e) << endl;
cout << sizeof_v(n) << endl;
cout << sizeof_t(Empty) << endl;
cout << sizeof_t(int) << endl;
cout << ALIGN(0, 16) <<endl;
cout << ALIGN(2, 16) <<endl;
cout << ALIGN(16, 16) <<endl;
cout << ALIGN(31, 16) <<endl;
return 0;
}