I expected the two unordered sets below to be evaluated as equivalent, but to my surprise this is not the case. This is because two lines are stored in the same hash cache, and the == operator performs sequential comparisons for elements in the set. Should this be considered an error in std :: unordered_set? Does anyone have an elegant workaround for this?
std::unordered_set<std::string> a,b;
a.insert("500666");
a.insert("961021");
b.insert("961021");
b.insert("500666");
if (a == b)
{
}
source
share