The unordered associative containers unordered_set
, unordered_map
etc do not have a less than operator operator<
, neither as a member function nor as a free function. Why? There is no specialization of less
either. SGI STL's hash_*
types also lack this feature.
If we exclude the concept of underlying types, all container types fulfil the requirements of regular types as defined e.g. in Stepanov & McJones' Elements of Programming. The sole exception are the unordered associative types, which lack operator<
.
I could not come up with an efficient implementation of such an operator that is consistent with the given definition of equality, so might efficiency be the reason? On the other hand, operator==
for unordered associative containers in some cases needs to rehash every element of one container and look it up in the other - O(N) average, but worst case O(N²).