Stl Set and struct comparison
I have a struct:
Code:
struct aCoord {
int a,b;
};
and a set of them:
Code:
std::set<aCoord> myCoords;
In one of my functions, I would like to check whether a newly generated aCoord is equivalent to one of the elements already in myCoords (meaning check whether firstCoord.a==secondCoord.a && firstCoord.b == secondCoord.b).
I have an iterator and am doing the following:
Code:
iterator = myCoords.find(newCoord);
if(iterator == myCoords.end()) {
myCoords.insert(newCoord);
}
This doesn't work because I need to overload the comparison function used by find, but despite the research I've done so far, I can't figure out the proper form of the operator override. Can anyone help me out? Thanks.