diff options
author | Andrei Errapart <andrei@errapartengineering.com> | 2015-08-24 22:49:23 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-09-01 12:40:24 +0200 |
commit | 09176bcf3f48f3b7d56ba6a176b273c086fea791 (patch) | |
tree | bf88820928b5a115342b921c62bdb8d43988ced6 | |
parent | 744a5333f5ee5105d539d152feff4c339f06804b (diff) | |
download | yosys-09176bcf3f48f3b7d56ba6a176b273c086fea791.tar.gz yosys-09176bcf3f48f3b7d56ba6a176b273c086fea791.tar.bz2 yosys-09176bcf3f48f3b7d56ba6a176b273c086fea791.zip |
Microsoft Visual C++ fixes in hashlib; template specializations on int32_t and int64_t.
-rw-r--r-- | kernel/hashlib.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h index f94945eca..3cc95b6e4 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -63,18 +63,21 @@ struct hash_int_ops { static inline bool cmp(T a, T b) { return a == b; } +}; + +template<> struct hash_ops<int32_t> : hash_int_ops +{ static inline unsigned int hash(int32_t a) { return a; } +}; +template<> struct hash_ops<int64_t> : hash_int_ops +{ static inline unsigned int hash(int64_t a) { return mkhash(a, a >> 32); } }; -template<> struct hash_ops<int> : hash_int_ops {}; -template<> struct hash_ops<long> : hash_int_ops {}; -template<> struct hash_ops<long long> : hash_int_ops {}; - template<> struct hash_ops<std::string> { static inline bool cmp(const std::string &a, const std::string &b) { return a == b; @@ -118,10 +121,9 @@ template<typename T> struct hash_ops<std::vector<T>> { return a == b; } static inline unsigned int hash(std::vector<T> a) { - hash_ops<T> t_ops; unsigned int h = mkhash_init; for (auto k : a) - h = mkhash(h, t_ops.hash(k)); + h = mkhash(h, hash_ops<T>::hash(k)); return h; } }; |