Is this guaranteed by the C ++ standard that if I have two pointers of the same type whose value is nullptr, then the difference between these pointers is 0?
Is the predicate true in pseudo-mathematical notation?
ForAll x ForAll y (x == nullptr) ^ (y == nullptr) → (x - y == 0)
The simplest code example I can imagine:
int* x = nullptr;
int* y = nullptr;
assert(x - y == 0);
I suppose this boils down to: is it possible to have a proper implementation of the C ++ standard for which there are several representations of the nullptr bits that are compared only as equal because the equality operator does some magic?
source
share