断言意图:assert(!distNodePt == !indexNodePt)

Assertion intention: assert(!distNodePt == !indexNodePt)

这个断言的意图是什么?出于某种原因,我无法理解它。

// Instantiate pointers of two custom types
FloatNodeType      * distNodePt  =  distAcc.probe(origin);
Int32NodeType      * indexNodePt = indexAcc.probe(origin);

assert(!distNodePt == !indexNodePt); // What is this assertion trying to make sure?

assert(!distNodePt == !indexNodePt); // What is this assertion trying to make sure?

这会检查两个 指针都指向有效内存,或者两个 指针等于nullptr

请注意 ! 是必需的,否则您将比较实际地址,这不是一回事。