diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-05-06 19:22:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 19:22:38 -0700 |
commit | a489568e3641d2431eba94518add65fd928ab86d (patch) | |
tree | 02b6f7732f14a6e4cbb1a1413a778313dd43d1f4 /src | |
parent | edff400acf8d7d1fb26e373cbf1102438f4dee48 (diff) | |
download | binaryen-a489568e3641d2431eba94518add65fd928ab86d.tar.gz binaryen-a489568e3641d2431eba94518add65fd928ab86d.tar.bz2 binaryen-a489568e3641d2431eba94518add65fd928ab86d.zip |
Move std::hash specializations into the std namespace (#2835)
This hopefully fixes a build problem on older GCC as reported in
#2827.
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 { |