0

In C++, what guarantees are there, if any, for two types T1 and T2 so that

sizeof(T1*) == sizeof(T2*)

will always be true? It's not guaranteed, for example, that char* and int* will be the same size on all systems.

Sir Visto
  • 683
  • 1
  • 4
  • 9
  • The pointer size has to do with the addresses space, not the used object – JVApen Jun 11 '18 at 17:58
  • The existence of [`std::uintptr_t`](http://en.cppreference.com/w/cpp/types/integer) implies that `sizeof(T*) <= sizeof(std::uintptr_t)` though I'm not sure that includes function pointers. – François Andrieux Jun 11 '18 at 18:02
  • 1
    ...or method pointers. – Martin James Jun 11 '18 at 18:04
  • 1
    ...or mouse pointers. – Galik Jun 11 '18 at 18:05
  • Depends on the processor. The 16-bit processors that have a 16-bit address space would have a 2 byte pointer. Some processors have "near" pointer that is one byte. Other processors have 24 bit points; while some processors have 64 or more bits. There is no standard. – Thomas Matthews Jun 11 '18 at 20:36

0 Answers0