Fix TypedInteger hash compilation failure with stdlibc++
TypedInteger.h didn't include <functional> 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 <functional> 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 <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
a84ab48150
commit
581c407cd2
|
@ -16,6 +16,7 @@
|
|||
#define COMMON_HASHUTILS_H_
|
||||
|
||||
#include "common/Platform.h"
|
||||
#include "common/TypedInteger.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <functional>
|
||||
|
@ -27,6 +28,12 @@ size_t Hash(const T& value) {
|
|||
return std::hash<T>()(value);
|
||||
}
|
||||
|
||||
// Add hashing of TypedIntegers
|
||||
template <typename Tag, typename T>
|
||||
size_t Hash(const TypedInteger<Tag, T>& value) {
|
||||
return Hash(static_cast<T>(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.
|
||||
//
|
||||
|
|
|
@ -193,6 +193,7 @@ namespace detail {
|
|||
} // namespace detail
|
||||
|
||||
namespace std {
|
||||
|
||||
template <typename Tag, typename T>
|
||||
class numeric_limits<detail::TypedIntegerImpl<Tag, T>> : public numeric_limits<T> {
|
||||
public:
|
||||
|
@ -204,14 +205,6 @@ namespace std {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename Tag, typename T>
|
||||
class hash<detail::TypedIntegerImpl<Tag, T>> : private hash<T> {
|
||||
public:
|
||||
size_t operator()(detail::TypedIntegerImpl<Tag, T> value) const {
|
||||
return hash<T>::operator()(static_cast<T>(value));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // COMMON_TYPEDINTEGER_H_
|
||||
|
|
Loading…
Reference in New Issue