allow easy default to absl::Hash framework

This commit is contained in:
greg
2019-03-30 14:38:38 -04:00
parent e5c4e46bd5
commit 2836a43989
2 changed files with 11 additions and 5 deletions
Vendored
+2 -2
View File
@@ -96,8 +96,8 @@ The full types with template parameters can be found in the [parallel_hashmap/ph
## Changes to Abseil's hashmaps
- The default hash framework is std::hash, not absl::Hash
- The `erase(iterator)` and `erase(const_iterator)` both return an iterator to the element following the removed element, as the do the std::unordered_map. A non-standard `void _erase(iterator)` is provided in case the return value is not needed.
- The default hash framework is std::hash, not absl::Hash. However, if you prefer the default to be the Abseil hash framework, include the Abseil headers before `phmap.h` and define the preprocessor macro `PHMAP_USE_ABSL_HASHEQ`.
- The `erase(iterator)` and `erase(const_iterator)` both return an iterator to the element following the removed element, as does the std::unordered_map. A non-standard `void _erase(iterator)` is provided in case the return value is not needed.
- No new types, such as `absl::string_view`, are provided. `std::string_view` is supported by phmap tables when built with a stdlib providing this type.
+9 -3
View File
@@ -24,11 +24,15 @@ namespace phmap {
template <class T, class E = void>
struct HashEq
{
#ifdef PHMAP_USE_ABSL_HASHEQ
using Hash = absl::Hash<T>;
using Eq = absl::EqualTo<T>;
#else
using Hash = phmap::Hash<T>;
using Eq = phmap::EqualTo<T>;
#endif
};
template <class T>
using hash_default_hash = typename container_internal::HashEq<T>::Hash;
@@ -36,10 +40,12 @@ namespace phmap {
using hash_default_eq = typename container_internal::HashEq<T>::Eq;
// type alias for std::allocator so we can forward declare without including other headers
template <class T> using Allocator = typename phmap::Allocator<T>;
template <class T>
using Allocator = typename phmap::Allocator<T>;
// type alias for std::pair so we can forward declare without including other headers
template<class T1, class T2> using Pair = typename phmap::Pair<T1, T2>;
template<class T1, class T2>
using Pair = typename phmap::Pair<T1, T2>;
} // namespace container_internal