diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-type.h | 8 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 19 |
2 files changed, 17 insertions, 10 deletions
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<wasm::Type> { +namespace std { + +template<> class hash<wasm::Type> { public: size_t operator()(const wasm::Type& type) const; }; -template<> class std::hash<wasm::Signature> { +template<> class hash<wasm::Signature> { 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<std::vector<wasm::Type>> { +namespace std { + +template<> class hash<vector<wasm::Type>> { public: - size_t operator()(const std::vector<wasm::Type>& types) const { + size_t operator()(const vector<wasm::Type>& 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<wasm::Type>::operator()(const wasm::Type& type) const { - return std::hash<uint64_t>{}(type.getID()); +size_t hash<wasm::Type>::operator()(const wasm::Type& type) const { + return hash<uint64_t>{}(type.getID()); } -size_t std::hash<wasm::Signature>:: -operator()(const wasm::Signature& sig) const { - return wasm::rehash(uint64_t(std::hash<uint64_t>{}(sig.params.getID())), - uint64_t(std::hash<uint64_t>{}(sig.results.getID()))); +size_t hash<wasm::Signature>::operator()(const wasm::Signature& sig) const { + return wasm::rehash(uint64_t(hash<uint64_t>{}(sig.params.getID())), + uint64_t(hash<uint64_t>{}(sig.results.getID()))); } +} // namespace std + namespace wasm { namespace { |