I want to store some pointers into std::set, but the standard guide says it\'s invalid.
If two pointers p and q of the same type point to different ob
While it is true that built-in operator <
only works for pointers into the same array, std::set
and std::map
don't use that operator - they use std::less
. This, in turn, is guaranteed to impose a total order on all pointers:
[comparisons]/2 For templates
less
,greater
,less_equal
, andgreater_equal
, the specializations for any pointer type yield a strict total order that is consistent among those specializations and is also consistent with the partial order imposed by the built-in operators<
,>
,<=
,>=
.