The function that will be used in std::set::find() is an instance of the Comparator class that you declared as a template parameter of your set.
template < class Key, class Compare = less<Key>, class Allocator = allocator<Key> > class set;
Specifically, a comparator instance will be passed to Key objects and should return true if the first is before the second. So yes, your implementation is fine.
Now, to dig further: if you want to convince yourself, you can delve into the source code of the gccs implementation of the standard library, and you will find:
template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: find(const _Key& __k) { iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); return (__j == end() || _M_impl._M_key_compare(__k, _S_key(__j._M_node))) ? end() : __j; }
You can see that _M_key_compare (which is an instance of the _Compare class that you provided) is called with __k as the first parameter (one of your Key ) and the return value is _S_key(...) which is the key. The return value of _M_key_compare used in the _M_key_compare expression, so it should be logical.
source share