From 932464ee079af65fa6188a9bd5cba76ad28eeb0e Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 30 Mar 2019 13:53:04 -0400 Subject: [PATCH] remove unused code, fix typos --- README.md | 2 +- parallel_hashmap/phmap_base.h | 521 +++++++++++++++++--------------- parallel_hashmap/phmap_config.h | 79 +---- parallel_hashmap/phmap_utils.h | 16 +- tests/hash_policy_testing.h | 2 +- 5 files changed, 283 insertions(+), 337 deletions(-) diff --git a/README.md b/README.md index 459d55d..ea6c182 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This repository aims to provide an set of excellent hash map implementations, wi - **drop-in replacement** for std::unordered_map and std::unordered_set -- Compiler with **C++11 support** required, **C++14 and C++17 APIs are provided** +- Compiler with **C++11 support** required, **C++14 and C++17 APIs are provided (such as `try_emplace`)** - **Very efficient**, significantly faster than your compiler's unordered map/set or Boost's, or than [sparsepp](https://github.com/greg7mdp/sparsepp) diff --git a/parallel_hashmap/phmap_base.h b/parallel_hashmap/phmap_base.h index 9814642..092bbee 100644 --- a/parallel_hashmap/phmap_base.h +++ b/parallel_hashmap/phmap_base.h @@ -3161,288 +3161,289 @@ using EnableIfConvertibleToSpanConst = // int* my_array = new int[10]; // MyRoutine(phmap::Span(my_array, 10)); template -class Span { - private: - // Used to determine whether a Span can be constructed from a container of - // type C. - template - using EnableIfConvertibleFrom = - typename std::enable_if::value && - span_internal::HasSize::value>::type; +class Span +{ +private: + // Used to determine whether a Span can be constructed from a container of + // type C. + template + using EnableIfConvertibleFrom = + typename std::enable_if::value && + span_internal::HasSize::value>::type; - // Used to SFINAE-enable a function when the slice elements are const. - template - using EnableIfConstView = - typename std::enable_if::value, U>::type; + // Used to SFINAE-enable a function when the slice elements are const. + template + using EnableIfConstView = + typename std::enable_if::value, U>::type; - // Used to SFINAE-enable a function when the slice elements are mutable. - template - using EnableIfMutableView = - typename std::enable_if::value, U>::type; + // Used to SFINAE-enable a function when the slice elements are mutable. + template + using EnableIfMutableView = + typename std::enable_if::value, U>::type; - public: - using value_type = phmap::remove_cv_t; - using pointer = T*; - using const_pointer = const T*; - using reference = T&; - using const_reference = const T&; - using iterator = pointer; - using const_iterator = const_pointer; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - using size_type = size_t; - using difference_type = ptrdiff_t; +public: + using value_type = phmap::remove_cv_t; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; + using iterator = pointer; + using const_iterator = const_pointer; + using reverse_iterator = std::reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; + using size_type = size_t; + using difference_type = ptrdiff_t; - static const size_type npos = ~(size_type(0)); + static const size_type npos = ~(size_type(0)); - constexpr Span() noexcept : Span(nullptr, 0) {} - constexpr Span(pointer array, size_type length) noexcept - : ptr_(array), len_(length) {} + constexpr Span() noexcept : Span(nullptr, 0) {} + constexpr Span(pointer array, size_type length) noexcept + : ptr_(array), len_(length) {} - // Implicit conversion constructors - template - constexpr Span(T (&a)[N]) noexcept // NOLINT(runtime/explicit) - : Span(a, N) {} + // Implicit conversion constructors + template + constexpr Span(T (&a)[N]) noexcept // NOLINT(runtime/explicit) + : Span(a, N) {} - // Explicit reference constructor for a mutable `Span` type. Can be - // replaced with MakeSpan() to infer the type parameter. - template , - typename = EnableIfMutableView> - explicit Span(V& v) noexcept // NOLINT(runtime/references) - : Span(span_internal::GetData(v), v.size()) {} + // Explicit reference constructor for a mutable `Span` type. Can be + // replaced with MakeSpan() to infer the type parameter. + template , + typename = EnableIfMutableView> + explicit Span(V& v) noexcept // NOLINT(runtime/references) + : Span(span_internal::GetData(v), v.size()) {} - // Implicit reference constructor for a read-only `Span` type - template , - typename = EnableIfConstView> - constexpr Span(const V& v) noexcept // NOLINT(runtime/explicit) - : Span(span_internal::GetData(v), v.size()) {} + // Implicit reference constructor for a read-only `Span` type + template , + typename = EnableIfConstView> + constexpr Span(const V& v) noexcept // NOLINT(runtime/explicit) + : Span(span_internal::GetData(v), v.size()) {} - // Implicit constructor from an initializer list, making it possible to pass a - // brace-enclosed initializer list to a function expecting a `Span`. Such - // spans constructed from an initializer list must be of type `Span`. - // - // void Process(phmap::Span x); - // Process({1, 2, 3}); - // - // Note that as always the array referenced by the span must outlive the span. - // Since an initializer list constructor acts as if it is fed a temporary - // array (cf. C++ standard [dcl.init.list]/5), it's safe to use this - // constructor only when the `std::initializer_list` itself outlives the span. - // In order to meet this requirement it's sufficient to ensure that neither - // the span nor a copy of it is used outside of the expression in which it's - // created: - // - // // Assume that this function uses the array directly, not retaining any - // // copy of the span or pointer to any of its elements. - // void Process(phmap::Span ints); - // - // // Okay: the std::initializer_list will reference a temporary array - // // that isn't destroyed until after the call to Process returns. - // Process({ 17, 19 }); - // - // // Not okay: the storage used by the std::initializer_list is not - // // allowed to be referenced after the first line. - // phmap::Span ints = { 17, 19 }; - // Process(ints); - // - // // Not okay for the same reason as above: even when the elements of the - // // initializer list expression are not temporaries the underlying array - // // is, so the initializer list must still outlive the span. - // const int foo = 17; - // phmap::Span ints = { foo }; - // Process(ints); - // - template > - Span( - std::initializer_list v) noexcept // NOLINT(runtime/explicit) - : Span(v.begin(), v.size()) {} + // Implicit constructor from an initializer list, making it possible to pass a + // brace-enclosed initializer list to a function expecting a `Span`. Such + // spans constructed from an initializer list must be of type `Span`. + // + // void Process(phmap::Span x); + // Process({1, 2, 3}); + // + // Note that as always the array referenced by the span must outlive the span. + // Since an initializer list constructor acts as if it is fed a temporary + // array (cf. C++ standard [dcl.init.list]/5), it's safe to use this + // constructor only when the `std::initializer_list` itself outlives the span. + // In order to meet this requirement it's sufficient to ensure that neither + // the span nor a copy of it is used outside of the expression in which it's + // created: + // + // // Assume that this function uses the array directly, not retaining any + // // copy of the span or pointer to any of its elements. + // void Process(phmap::Span ints); + // + // // Okay: the std::initializer_list will reference a temporary array + // // that isn't destroyed until after the call to Process returns. + // Process({ 17, 19 }); + // + // // Not okay: the storage used by the std::initializer_list is not + // // allowed to be referenced after the first line. + // phmap::Span ints = { 17, 19 }; + // Process(ints); + // + // // Not okay for the same reason as above: even when the elements of the + // // initializer list expression are not temporaries the underlying array + // // is, so the initializer list must still outlive the span. + // const int foo = 17; + // phmap::Span ints = { foo }; + // Process(ints); + // + template > + Span( + std::initializer_list v) noexcept // NOLINT(runtime/explicit) + : Span(v.begin(), v.size()) {} - // Accessors + // Accessors - // Span::data() - // - // Returns a pointer to the span's underlying array of data (which is held - // outside the span). - constexpr pointer data() const noexcept { return ptr_; } + // Span::data() + // + // Returns a pointer to the span's underlying array of data (which is held + // outside the span). + constexpr pointer data() const noexcept { return ptr_; } - // Span::size() - // - // Returns the size of this span. - constexpr size_type size() const noexcept { return len_; } + // Span::size() + // + // Returns the size of this span. + constexpr size_type size() const noexcept { return len_; } - // Span::length() - // - // Returns the length (size) of this span. - constexpr size_type length() const noexcept { return size(); } + // Span::length() + // + // Returns the length (size) of this span. + constexpr size_type length() const noexcept { return size(); } - // Span::empty() - // - // Returns a boolean indicating whether or not this span is considered empty. - constexpr bool empty() const noexcept { return size() == 0; } + // Span::empty() + // + // Returns a boolean indicating whether or not this span is considered empty. + constexpr bool empty() const noexcept { return size() == 0; } - // Span::operator[] - // - // Returns a reference to the i'th element of this span. - constexpr reference operator[](size_type i) const noexcept { - // MSVC 2015 accepts this as constexpr, but not ptr_[i] - return *(data() + i); - } + // Span::operator[] + // + // Returns a reference to the i'th element of this span. + constexpr reference operator[](size_type i) const noexcept { + // MSVC 2015 accepts this as constexpr, but not ptr_[i] + return *(data() + i); + } - // Span::at() - // - // Returns a reference to the i'th element of this span. - constexpr reference at(size_type i) const { - return PHMAP_PREDICT_TRUE(i < size()) // - ? *(data() + i) - : (base_internal::ThrowStdOutOfRange( - "Span::at failed bounds check"), - *(data() + i)); - } + // Span::at() + // + // Returns a reference to the i'th element of this span. + constexpr reference at(size_type i) const { + return PHMAP_PREDICT_TRUE(i < size()) // + ? *(data() + i) + : (base_internal::ThrowStdOutOfRange( + "Span::at failed bounds check"), + *(data() + i)); + } - // Span::front() - // - // Returns a reference to the first element of this span. - constexpr reference front() const noexcept { - return PHMAP_ASSERT(size() > 0), *data(); - } + // Span::front() + // + // Returns a reference to the first element of this span. + constexpr reference front() const noexcept { + return PHMAP_ASSERT(size() > 0), *data(); + } - // Span::back() - // - // Returns a reference to the last element of this span. - constexpr reference back() const noexcept { - return PHMAP_ASSERT(size() > 0), *(data() + size() - 1); - } + // Span::back() + // + // Returns a reference to the last element of this span. + constexpr reference back() const noexcept { + return PHMAP_ASSERT(size() > 0), *(data() + size() - 1); + } - // Span::begin() - // - // Returns an iterator to the first element of this span. - constexpr iterator begin() const noexcept { return data(); } + // Span::begin() + // + // Returns an iterator to the first element of this span. + constexpr iterator begin() const noexcept { return data(); } - // Span::cbegin() - // - // Returns a const iterator to the first element of this span. - constexpr const_iterator cbegin() const noexcept { return begin(); } + // Span::cbegin() + // + // Returns a const iterator to the first element of this span. + constexpr const_iterator cbegin() const noexcept { return begin(); } - // Span::end() - // - // Returns an iterator to the last element of this span. - constexpr iterator end() const noexcept { return data() + size(); } + // Span::end() + // + // Returns an iterator to the last element of this span. + constexpr iterator end() const noexcept { return data() + size(); } - // Span::cend() - // - // Returns a const iterator to the last element of this span. - constexpr const_iterator cend() const noexcept { return end(); } + // Span::cend() + // + // Returns a const iterator to the last element of this span. + constexpr const_iterator cend() const noexcept { return end(); } - // Span::rbegin() - // - // Returns a reverse iterator starting at the last element of this span. - constexpr reverse_iterator rbegin() const noexcept { - return reverse_iterator(end()); - } + // Span::rbegin() + // + // Returns a reverse iterator starting at the last element of this span. + constexpr reverse_iterator rbegin() const noexcept { + return reverse_iterator(end()); + } - // Span::crbegin() - // - // Returns a reverse const iterator starting at the last element of this span. - constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); } + // Span::crbegin() + // + // Returns a reverse const iterator starting at the last element of this span. + constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); } - // Span::rend() - // - // Returns a reverse iterator starting at the first element of this span. - constexpr reverse_iterator rend() const noexcept { - return reverse_iterator(begin()); - } + // Span::rend() + // + // Returns a reverse iterator starting at the first element of this span. + constexpr reverse_iterator rend() const noexcept { + return reverse_iterator(begin()); + } - // Span::crend() - // - // Returns a reverse iterator starting at the first element of this span. - constexpr const_reverse_iterator crend() const noexcept { return rend(); } + // Span::crend() + // + // Returns a reverse iterator starting at the first element of this span. + constexpr const_reverse_iterator crend() const noexcept { return rend(); } - // Span mutations + // Span mutations - // Span::remove_prefix() - // - // Removes the first `n` elements from the span. - void remove_prefix(size_type n) noexcept { - assert(size() >= n); - ptr_ += n; - len_ -= n; - } + // Span::remove_prefix() + // + // Removes the first `n` elements from the span. + void remove_prefix(size_type n) noexcept { + assert(size() >= n); + ptr_ += n; + len_ -= n; + } - // Span::remove_suffix() - // - // Removes the last `n` elements from the span. - void remove_suffix(size_type n) noexcept { - assert(size() >= n); - len_ -= n; - } + // Span::remove_suffix() + // + // Removes the last `n` elements from the span. + void remove_suffix(size_type n) noexcept { + assert(size() >= n); + len_ -= n; + } - // Span::subspan() - // - // Returns a `Span` starting at element `pos` and of length `len`. Both `pos` - // and `len` are of type `size_type` and thus non-negative. Parameter `pos` - // must be <= size(). Any `len` value that points past the end of the span - // will be trimmed to at most size() - `pos`. A default `len` value of `npos` - // ensures the returned subspan continues until the end of the span. - // - // Examples: - // - // std::vector vec = {10, 11, 12, 13}; - // phmap::MakeSpan(vec).subspan(1, 2); // {11, 12} - // phmap::MakeSpan(vec).subspan(2, 8); // {12, 13} - // phmap::MakeSpan(vec).subspan(1); // {11, 12, 13} - // phmap::MakeSpan(vec).subspan(4); // {} - // phmap::MakeSpan(vec).subspan(5); // throws std::out_of_range - constexpr Span subspan(size_type pos = 0, size_type len = npos) const { - return (pos <= size()) - ? Span(data() + pos, span_internal::Min(size() - pos, len)) - : (base_internal::ThrowStdOutOfRange("pos > size()"), Span()); - } + // Span::subspan() + // + // Returns a `Span` starting at element `pos` and of length `len`. Both `pos` + // and `len` are of type `size_type` and thus non-negative. Parameter `pos` + // must be <= size(). Any `len` value that points past the end of the span + // will be trimmed to at most size() - `pos`. A default `len` value of `npos` + // ensures the returned subspan continues until the end of the span. + // + // Examples: + // + // std::vector vec = {10, 11, 12, 13}; + // phmap::MakeSpan(vec).subspan(1, 2); // {11, 12} + // phmap::MakeSpan(vec).subspan(2, 8); // {12, 13} + // phmap::MakeSpan(vec).subspan(1); // {11, 12, 13} + // phmap::MakeSpan(vec).subspan(4); // {} + // phmap::MakeSpan(vec).subspan(5); // throws std::out_of_range + constexpr Span subspan(size_type pos = 0, size_type len = npos) const { + return (pos <= size()) + ? Span(data() + pos, span_internal::Min(size() - pos, len)) + : (base_internal::ThrowStdOutOfRange("pos > size()"), Span()); + } - // Span::first() - // - // Returns a `Span` containing first `len` elements. Parameter `len` is of - // type `size_type` and thus non-negative. `len` value must be <= size(). - // - // Examples: - // - // std::vector vec = {10, 11, 12, 13}; - // phmap::MakeSpan(vec).first(1); // {10} - // phmap::MakeSpan(vec).first(3); // {10, 11, 12} - // phmap::MakeSpan(vec).first(5); // throws std::out_of_range - constexpr Span first(size_type len) const { - return (len <= size()) - ? Span(data(), len) - : (base_internal::ThrowStdOutOfRange("len > size()"), Span()); - } + // Span::first() + // + // Returns a `Span` containing first `len` elements. Parameter `len` is of + // type `size_type` and thus non-negative. `len` value must be <= size(). + // + // Examples: + // + // std::vector vec = {10, 11, 12, 13}; + // phmap::MakeSpan(vec).first(1); // {10} + // phmap::MakeSpan(vec).first(3); // {10, 11, 12} + // phmap::MakeSpan(vec).first(5); // throws std::out_of_range + constexpr Span first(size_type len) const { + return (len <= size()) + ? Span(data(), len) + : (base_internal::ThrowStdOutOfRange("len > size()"), Span()); + } - // Span::last() - // - // Returns a `Span` containing last `len` elements. Parameter `len` is of - // type `size_type` and thus non-negative. `len` value must be <= size(). - // - // Examples: - // - // std::vector vec = {10, 11, 12, 13}; - // phmap::MakeSpan(vec).last(1); // {13} - // phmap::MakeSpan(vec).last(3); // {11, 12, 13} - // phmap::MakeSpan(vec).last(5); // throws std::out_of_range - constexpr Span last(size_type len) const { - return (len <= size()) - ? Span(size() - len + data(), len) - : (base_internal::ThrowStdOutOfRange("len > size()"), Span()); - } + // Span::last() + // + // Returns a `Span` containing last `len` elements. Parameter `len` is of + // type `size_type` and thus non-negative. `len` value must be <= size(). + // + // Examples: + // + // std::vector vec = {10, 11, 12, 13}; + // phmap::MakeSpan(vec).last(1); // {13} + // phmap::MakeSpan(vec).last(3); // {11, 12, 13} + // phmap::MakeSpan(vec).last(5); // throws std::out_of_range + constexpr Span last(size_type len) const { + return (len <= size()) + ? Span(size() - len + data(), len) + : (base_internal::ThrowStdOutOfRange("len > size()"), Span()); + } - // Support for phmap::Hash. - template - friend H PhmapHashValue(H h, Span v) { - return H::combine(H::combine_contiguous(std::move(h), v.data(), v.size()), - v.size()); - } + // Support for phmap::Hash. + template + friend H AbslHashValue(H h, Span v) { + return H::combine(H::combine_contiguous(std::move(h), v.data(), v.size()), + v.size()); + } - private: - pointer ptr_; - size_type len_; +private: + pointer ptr_; + size_type len_; }; template @@ -3467,19 +3468,23 @@ template bool operator==(Span a, Span b) { return span_internal::EqualImpl(a, b); } + template bool operator==(Span a, Span b) { return span_internal::EqualImpl(a, b); } + template bool operator==(Span a, Span b) { return span_internal::EqualImpl(a, b); } + template > bool operator==(const U& a, Span b) { return span_internal::EqualImpl(a, b); } + template > bool operator==(Span a, const U& b) { @@ -3491,19 +3496,23 @@ template bool operator!=(Span a, Span b) { return !(a == b); } + template bool operator!=(Span a, Span b) { return !(a == b); } + template bool operator!=(Span a, Span b) { return !(a == b); } + template > bool operator!=(const U& a, Span b) { return !(a == b); } + template > bool operator!=(Span a, const U& b) { @@ -3515,19 +3524,23 @@ template bool operator<(Span a, Span b) { return span_internal::LessThanImpl(a, b); } + template bool operator<(Span a, Span b) { return span_internal::LessThanImpl(a, b); } + template bool operator<(Span a, Span b) { return span_internal::LessThanImpl(a, b); } + template > bool operator<(const U& a, Span b) { return span_internal::LessThanImpl(a, b); } + template > bool operator<(Span a, const U& b) { @@ -3539,19 +3552,23 @@ template bool operator>(Span a, Span b) { return b < a; } + template bool operator>(Span a, Span b) { return b < a; } + template bool operator>(Span a, Span b) { return b < a; } + template > bool operator>(const U& a, Span b) { return b < a; } + template > bool operator>(Span a, const U& b) { @@ -3563,19 +3580,23 @@ template bool operator<=(Span a, Span b) { return !(b < a); } + template bool operator<=(Span a, Span b) { return !(b < a); } + template bool operator<=(Span a, Span b) { return !(b < a); } + template > bool operator<=(const U& a, Span b) { return !(b < a); } + template > bool operator<=(Span a, const U& b) { @@ -3587,19 +3608,23 @@ template bool operator>=(Span a, Span b) { return !(a < b); } + template bool operator>=(Span a, Span b) { return !(a < b); } + template bool operator>=(Span a, Span b) { return !(a < b); } + template > bool operator>=(const U& a, Span b) { return !(a < b); } + template > bool operator>=(Span a, const U& b) { diff --git a/parallel_hashmap/phmap_config.h b/parallel_hashmap/phmap_config.h index 3208260..e3e7573 100644 --- a/parallel_hashmap/phmap_config.h +++ b/parallel_hashmap/phmap_config.h @@ -648,81 +648,16 @@ // can be used in defining new arrays. If you use this macro on a pointer by // mistake, you will get a compile-time error. #define PHMAP_ARRAYSIZE(array) \ - (sizeof(::absl::macros_internal::ArraySizeHelper(array))) + (sizeof(::phmap::macros_internal::ArraySizeHelper(array))) -namespace absl { +namespace phmap { namespace macros_internal { -// Note: this internal template function declaration is used by PHMAP_ARRAYSIZE. -// The function doesn't need a definition, as we only use its type. -template -auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; + // Note: this internal template function declaration is used by PHMAP_ARRAYSIZE. + // The function doesn't need a definition, as we only use its type. + template + auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; } // namespace macros_internal -} // namespace absl - -// kLinkerInitialized -// -// An enum used only as a constructor argument to indicate that a variable has -// static storage duration, and that the constructor should do nothing to its -// state. Use of this macro indicates to the reader that it is legal to -// declare a static instance of the class, provided the constructor is given -// the absl::base_internal::kLinkerInitialized argument. -// -// Normally, it is unsafe to declare a static variable that has a constructor or -// a destructor because invocation order is undefined. However, if the type can -// be zero-initialized (which the loader does for static variables) into a valid -// state and the type's destructor does not affect storage, then a constructor -// for static initialization can be declared. -// -// Example: -// // Declaration -// explicit MyClass(absl::base_internal:LinkerInitialized x) {} -// -// // Invocation -// static MyClass my_global(absl::base_internal::kLinkerInitialized); -namespace absl { -namespace base_internal { -enum LinkerInitialized { - kLinkerInitialized = 0, -}; -} // namespace base_internal -} // namespace absl - -// PHMAP_FALLTHROUGH_INTENDED -// -// Annotates implicit fall-through between switch labels, allowing a case to -// indicate intentional fallthrough and turn off warnings about any lack of a -// `break` statement. The PHMAP_FALLTHROUGH_INTENDED macro should be followed by -// a semicolon and can be used in most places where `break` can, provided that -// no statements exist between it and the next switch label. -// -// Example: -// -// switch (x) { -// case 40: -// case 41: -// if (truth_is_out_there) { -// ++x; -// PHMAP_FALLTHROUGH_INTENDED; // Use instead of/along with annotations -// // in comments -// } else { -// return x; -// } -// case 42: -// ... -// -// Notes: when compiled with clang in C++11 mode, the PHMAP_FALLTHROUGH_INTENDED -// macro is expanded to the [[clang::fallthrough]] attribute, which is analysed -// when performing switch labels fall-through diagnostic -// (`-Wimplicit-fallthrough`). See clang documentation on language extensions -// for details: -// http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough -// -// When used with unsupported compilers, the PHMAP_FALLTHROUGH_INTENDED macro -// has no effect on diagnostics. In any case this macro has no effect on runtime -// behavior and performance of code. -#ifdef PHMAP_FALLTHROUGH_INTENDED - #error "PHMAP_FALLTHROUGH_INTENDED should not be defined." -#endif +} // namespace phmap // TODO(zhangxy): Use c++17 standard [[fallthrough]] macro, when supported. #if defined(__clang__) && defined(__has_warning) diff --git a/parallel_hashmap/phmap_utils.h b/parallel_hashmap/phmap_utils.h index 5cf9a8a..60ce20e 100644 --- a/parallel_hashmap/phmap_utils.h +++ b/parallel_hashmap/phmap_utils.h @@ -41,9 +41,6 @@ namespace phmap { -template T phmap_min(T a, T b) { return a < b ? a : b; } -template T phmap_max(T a, T b) { return a >= b ? a : b; } - template using Allocator = typename std::allocator; template using Pair = typename std::pair; @@ -69,20 +66,9 @@ struct Hash template struct Hash { - static size_t phmap_log2 (size_t val) noexcept - { - size_t res = 0; - while (val > 1) - { - val >>= 1; - res++; - } - return res; - } - inline size_t operator()(const T *__v) const noexcept { - static const size_t shift = 3; // phmap_log2(1 + sizeof(T)); // T might be incomplete! + static const size_t shift = 3; const uintptr_t i = (const uintptr_t)__v; return static_cast(i >> shift); } diff --git a/tests/hash_policy_testing.h b/tests/hash_policy_testing.h index 99652e1..9209f90 100644 --- a/tests/hash_policy_testing.h +++ b/tests/hash_policy_testing.h @@ -165,7 +165,7 @@ auto keys(const Set& s) namespace std { - // inject specialization of std::hash for Person into namespace std + // inject specialization of std::hash for NonStandardLayout into namespace std // ---------------------------------------------------------------- template<> struct hash