Is the following code 100% portable?
int a=10;
size_t size_of_int = (char *)(&a+1)-(char*)(&a); // No problem here?
std::cout<
It's not 100% portable for the following reasons:
int a[1]; and then a+1 becomes definitively valid.int type, size_of_int will not contain the correct answer.I am uncertain if the above hold for C++.