I have this class with an overloaded comparator:
struct Foo {
int x;
bool operator < (Foo other) const {
return x < other.x;
}
bool operator < (int val) const {
return x < val;
}
};
and I make a set on it:
set<Foo> s;
I'm allowed to call lower_bound() on a Foo, but not on an int (as you would expect).
s.lower_bound(Foo{3}); // works
s.lower_bound(3); //"no matching member function for call to 'lower_bound'
But if instead I declare s with a less<> :
set<Foo,less<>>
Both calls work:
s.lower_bound({3});
s.lower_bound(3);
Why?