Closed tuket closed 4 years ago
The idea was to provide heterogenous lookup.
Here is the problem: Say you have e.g. a robin_hood::unordered_map<std::string, int>
, and you want to perform lookups but have only e.g. a std::string_view
. With the standard interface you need to create a new std::string
that's a copy of the std::string_view
content to perform the lookup. That's quite a lot of overhead.
The idea is that with is_transparent_tag
you create a robin_hood::unordered_map<std::string, int, robin_hood::hash<>, std::equal_to<>> map
, and then you can do a lookup with a stringview that can directly hash the stringview and does not need to create a temporary copy.
The interface is currently not working though, because due to lots of refactoring this doesn't work any more. I need to update this.
More info here: https://abseil.io/tips/144 and here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0919r1.html
I'll leave your question open until I have proper support for this, thanks for reminding me!
Latest paper: "Refinement Proposal for P0919 Heterogeneous lookup for unordered containers" http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1690r0.html
you create a
robin_hood::unordered_map<std::string, int, robin_hood::hash<>, std::equal_to<>>
map
Do you mind explaining how this works? It doesn't look like robin_hood::hash
has is_transparent
like std::equal_to
has
I see there is a version of
find
that takesis_transparent_tag
a parameter. What is it for?Thanks