Does casting pointers to integers define a total order on pointers?
问题 (related to my previous question) In QT, the QMap documentation says: The key type of a QMap must provide operator<() specifying a total order . However, in qmap.h , they seem to use something similar to std::less to compare pointers: /* QMap uses qMapLessThanKey() to compare keys. The default implementation uses operator<(). For pointer types, qMapLessThanKey() casts the pointers to integers before it compares them, because operator<() is undefined on pointers that come from different memory