When is an integer<->pointer cast actually correct?

后端 未结 15 2662
北荒
北荒 2020-12-13 07:48

The common folklore says that:

  • The type system exists for a reason. Integers and pointers are distinct types, casting between them is a malpractice in the m

15条回答
  •  长情又很酷
    2020-12-13 08:28

    Storing a doubly linked list using half the space

    A XOR Linked List combines the next and prev pointers into a single value of the same size. It does this by xor-ing the two pointers together, which requires treating them like integers.

提交回复
热议问题