From a489568e3641d2431eba94518add65fd928ab86d Mon Sep 17 00:00:00 2001 From: Thomas Lively <7121787+tlively@users.noreply.github.com> Date: Wed, 6 May 2020 19:22:38 -0700 Subject: Move std::hash specializations into the std namespace (#2835) This hopefully fixes a build problem on older GCC as reported in #2827. --- src/wasm-type.h | 8 ++++++-- src/wasm/wasm-type.cpp | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/wasm-type.h b/src/wasm-type.h index 6e74f0338..cfd47a8e0 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -173,14 +173,18 @@ std::ostream& operator<<(std::ostream& os, Signature t); } // namespace wasm -template<> class std::hash { +namespace std { + +template<> class hash { public: size_t operator()(const wasm::Type& type) const; }; -template<> class std::hash { +template<> class hash { public: size_t operator()(const wasm::Signature& sig) const; }; +} // namespace std + #endif // wasm_wasm_type_h diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 7d51cc10e..8467e2176 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -25,9 +25,11 @@ #include "wasm-features.h" #include "wasm-type.h" -template<> class std::hash> { +namespace std { + +template<> class hash> { public: - size_t operator()(const std::vector& types) const { + size_t operator()(const vector& types) const { uint64_t res = wasm::rehash(0, uint32_t(types.size())); for (auto t : types) { res = wasm::rehash(res, t.getID()); @@ -36,16 +38,17 @@ public: } }; -size_t std::hash::operator()(const wasm::Type& type) const { - return std::hash{}(type.getID()); +size_t hash::operator()(const wasm::Type& type) const { + return hash{}(type.getID()); } -size_t std::hash:: -operator()(const wasm::Signature& sig) const { - return wasm::rehash(uint64_t(std::hash{}(sig.params.getID())), - uint64_t(std::hash{}(sig.results.getID()))); +size_t hash::operator()(const wasm::Signature& sig) const { + return wasm::rehash(uint64_t(hash{}(sig.params.getID())), + uint64_t(hash{}(sig.results.getID()))); } +} // namespace std + namespace wasm { namespace { -- cgit v1.2.3