Reputation: 2711
Is there a reason that std::tr1::unordered_map left out the equality (==) operator, which exists for std::map ?
What is a good way to implement this? I am thinking of creating two sets of unordered_map::value_type, initializing them from the two hash_maps and then checking for equality of the two sets.
Upvotes: 2
Views: 585
Reputation: 219345
It was a committee decision that imho was a mistake. It has been corrected for std::unordered_map (in C++11).
Using std::equal
is not a good way to find the equality of unordered containers. After all, they may not be in the same order.
N3068 is the paper that introduced equality comparisons for the unordered containers. It explains the motivation and the technique for determining equality.
Upvotes: 6