开发者

C++ equality in std::tr1::unordered_map

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜