heterogeneous string keys by default in F14, with general mechanism
Summary: This diff adds folly types HeterogeneousAccessLess<T>, HeterogeneousAccessEqualTo<T>, and HeterogeneousAccessHash<T> that are suitable as the default functor types for containers that support heterogeneous access, and it makes those the default for F14 maps and sets. The new functor types will be marked as transparent when possible, otherwise they will fall back to the non-transparent std::less<T>, std::equal_to<T>, and std::hash<T> respectively. Heterogeneous lookup is provided for types that are implicitly convertible to Range<T const*>, where T is an integral type. This includes std::string, std::string_view (when available), folly::StringPiece, folly::MutableStringPiece, std::array, std::vector, folly::small_vector. HeterogeneousAccessHash<T> will use folly::hasher<folly::Range< T::value_type const*>> for hashing when it provides a transparent hash, except that for libstdc++ and libc++ we special-case the case hashing Range<char const*> to use the same hash function as std::string. That makes this diff performance neutral for existing use cases. Reviewed By: ot Differential Revision: D8768761 fbshipit-source-id: ded7c86e30479409cf838ac8219241622a4e2332
Showing
Please register or sign in to comment