Why are these C ++ STL unordered sets considered equal?

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)   // condition is evaulated as false
{   
}
+5
source share
1 answer

Visual ++ 2010. ​​ Visual ++ 2012; , , . ( Microsoft Connect, , , , , .)

, - , .

+4

All Articles