Consider:
struct Foo { bool operator<(const Foo&) const;}; struct Bar { operator Foo() const; }; std::set<Foo> s; Bar b; s.find(b);
By default, s uses std::less<Foo> , and s.find() takes const Foo & , so lookup creates one temporary Foo from Bar and uses it for all comparisons.
In contrast, if s were changed to the transparent comparison functor std::less<> , then in combination with heterogeneous search, each comparison in find() will be between a Foo and a Bar , so each comparison will build a temporary Foo . This is a silent performance degradation.
source share