Is the following code 100% portable?
int a=10; size_t size_of_int = (char *)(&a+1)-(char*)(&a); // No problem here? std::cout<
The code above will portably compute sizeof(int) on a target platform but the latter is implementation defined - you will get different results on different platforms.
sizeof(int)