From 581c407cd20badc71e3b8e5536e5a1ac47d5b6ba Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 18 Jun 2020 09:00:48 +0000 Subject: [PATCH] Fix TypedInteger hash compilation failure with stdlibc++ TypedInteger.h didn't include which made the reference to std::hash cause a compilation failure. Fix this by moving TypedInteger hashing to HashUtils.h so that TypedInteger doesn't include in all of its users. Bug: dawn:442 Change-Id: I5a0271bb187682616eb5ef3a13bb7f6271203453 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23440 Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- src/common/HashUtils.h | 7 +++++++ src/common/TypedInteger.h | 9 +-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/HashUtils.h b/src/common/HashUtils.h index c42b60e02e..a316dbcd80 100644 --- a/src/common/HashUtils.h +++ b/src/common/HashUtils.h @@ -16,6 +16,7 @@ #define COMMON_HASHUTILS_H_ #include "common/Platform.h" +#include "common/TypedInteger.h" #include #include @@ -27,6 +28,12 @@ size_t Hash(const T& value) { return std::hash()(value); } +// Add hashing of TypedIntegers +template +size_t Hash(const TypedInteger& value) { + return Hash(static_cast(value)); +} + // When hashing sparse structures we want to iteratively build a hash value with only parts of the // data. HashCombine "hashes" together an existing hash and hashable values. // diff --git a/src/common/TypedInteger.h b/src/common/TypedInteger.h index 05450ec258..dd06331cd6 100644 --- a/src/common/TypedInteger.h +++ b/src/common/TypedInteger.h @@ -193,6 +193,7 @@ namespace detail { } // namespace detail namespace std { + template class numeric_limits> : public numeric_limits { public: @@ -204,14 +205,6 @@ namespace std { } }; - template - class hash> : private hash { - public: - size_t operator()(detail::TypedIntegerImpl value) const { - return hash::operator()(static_cast(value)); - } - }; - } // namespace std #endif // COMMON_TYPEDINTEGER_H_