How can pointers be totally ordered?
问题 Pointers in C++ may in general only be compared for equality. By contrast, less-than comparison is only allowed for two pointers that point to subobjects of the same complete object (e.g. array elements). So given T * p, * q , it is illegal in general to evaluate p < q . The standard library contains functor class templates std::less<T> etc. which wrap the built-in operator < . However, the standard has this to say about pointer types (20.8.5/8): For templates greater , less , greater_equal ,