Click here to Skip to main content
15,921,467 members

Comments by fuzzy27 (Top 2 by date)

fuzzy27 10-Jun-14 12:01pm View    
I guess I tried all the combinations involving const except the right one (that's why const was still on the return types). In the end, only the Bar operator requires const.
Thanks to everyone who replied.
fuzzy27 10-Jun-14 2:31am View    
Thanks for your prompt answer KarstenK.

In the two examples, the comparison is done in the same place. The difference is that in one case the pair consists of <int, string=""> and in the other the pair is <bar, bar="">. You are correct when you say that each member of the pair has to be compared. When the pair members are <int, string="">, std::pair::operator== for can compare them; I don't have to do anything extra. When the pair members are objects, std::pair::operator== should be able to compare them if I've defined (in this case) Bar::operator==. This operator is defined, but the code doesn't compile. The first error message says that Bar::operator== was not found, which means it was looking for it so pair::operator== could use it. But why is it not found?
Is the definition wrong? Is it in the wrong place?