Round-trip safety of storing integer in void pointer

前端 未结 2 756
余生分开走
余生分开走 2021-01-19 15:00

In this article the following is mentioned regarding reinterpret_cast of integers and pointers:

(the round-trip conversi

2条回答
  •  爱一瞬间的悲伤
    2021-01-19 15:31

    There might not be an integral type that exactly matches the width of the platform's address space. intptr_t has to be big enough to hold any pointer value, meaning it is as big or bigger than a pointer, and when it is bigger, the pigeonhole principle guarantees that it won't be possible for each integer value to have a unique void* value.

提交回复
热议问题