hetergenenous key lookup - std::map::find template method
Why does eastl::rbtree have to provide these:
template <typename U, typename Compare2> iterator find_as(const U& u, Compare2 compare2);
template <typename U, typename Compare2> const_iterator find_as(const U& u, Compare2 compare2) const;
instead of using the std way of achieving this by supplying an explicit std::less<> instead of relying on the default std::less<T> as the compare class template argument, and using the following transparent query methods instead:
template< class K > iterator find( const K& x );
template< class K > const_iterator find( const K& x ) const;
which do not require an (explicit) compare object to be passed. That way one can just pass std::string_view for instance to a std::map with std::string keys without having to construct an actual std::string for the lookup.
Maybe it is possible to even go one step further and just use std::less<> and eastl::less<> as defaults?
This is how EASTL achieved heterogeneous key lookup before the standard adopted the change. ie. using a 'const char*' to find a key of type 'eastl::string'.
https://abseil.io/tips/144
I haven't done the work to make our containers compliant in this area. Its on my list of things but users haven't been raising it as a high priority due EASTL already have similar feature set. But there is value in making it standards compliant so it needs to get done at some point in the future.
It would idd. be nice to be as standard compliant as possible iff it does not undermine the goals of EASTL, so having the template member method eventually would be nice. I would imho, however, deviate from the standard and use eastl::less<> as the default. Not sure if this would actually break some existing code (it seems rather a generalization covering the current use) or if the standard is ever going to use that as well.