I have a struct like:
struct point{
int f;
int b;
point(){}
point(int u, int v){
f = u; b = v;
}
bool operator<(const point & foo) const {
return this->f < foo.f;
}
bool operator<(int foo) const {
return this->f < foo;
}
};
how can I use int as parameter instead of using point?
set<point> s;
-> s.find(3);
I was confused, if I have a key_type value with the key I need(such as point(3,4)), why I need to find it in std::set?
One can ask: Does set X contain value Y? (Then again, set::count() gives that result too.)
Note also that your partial match returns at most one point with set::find(), while the set may contain multiple unique points that all have point::f == 3. Surely you want them all?