Is there an integral type with the same size and alignment as a pointer?

Is there an integral type with the same size and alignment as a pointer?

There are std::intptr_t and std::uintptr_t , but I believe that they do not have the same alignment as the pointer.

+5
source share
1 answer

It is not required that all types of pointers have the same size and alignment, which does not allow one type of integer type to have the same size and alignment for all types of pointers.

Of course, object pointers, function pointers, and member pointers have different requirements. But on some platforms, even char* and int* are of different sizes.

+4
source

Source: https://habr.com/ru/post/1236978/


All Articles