diff --git a/README.md b/README.md index ea6c182..c67db03 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/parallel_hashmap/phmap_fwd_decl.h b/parallel_hashmap/phmap_fwd_decl.h index a0e2e40..f1b212e 100644 --- a/parallel_hashmap/phmap_fwd_decl.h +++ b/parallel_hashmap/phmap_fwd_decl.h @@ -24,11 +24,15 @@ namespace phmap { template struct HashEq { +#ifdef PHMAP_USE_ABSL_HASHEQ + using Hash = absl::Hash; + using Eq = absl::EqualTo; +#else using Hash = phmap::Hash; using Eq = phmap::EqualTo; +#endif }; - template using hash_default_hash = typename container_internal::HashEq::Hash; @@ -36,10 +40,12 @@ namespace phmap { using hash_default_eq = typename container_internal::HashEq::Eq; // type alias for std::allocator so we can forward declare without including other headers - template using Allocator = typename phmap::Allocator; + template + using Allocator = typename phmap::Allocator; // type alias for std::pair so we can forward declare without including other headers - template using Pair = typename phmap::Pair; + template + using Pair = typename phmap::Pair; } // namespace container_internal