diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-04-07 17:23:30 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-04-07 17:23:30 +0200 |
commit | aae5f2ca0873d3a2a96f51d70b3b5bc2f2d0bcf9 (patch) | |
tree | aa2c760e7eef0956dce19fd2b9c935625a3ca40f /kernel | |
parent | f7fb21f1853ec6a0a711624e4f53a75321639b18 (diff) | |
download | yosys-aae5f2ca0873d3a2a96f51d70b3b5bc2f2d0bcf9.tar.gz yosys-aae5f2ca0873d3a2a96f51d70b3b5bc2f2d0bcf9.tar.bz2 yosys-aae5f2ca0873d3a2a96f51d70b3b5bc2f2d0bcf9.zip |
Added hashlib support for std::tuple<>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/hashlib.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 7cea195d5..b6cedc496 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -92,6 +92,21 @@ template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> { } }; +template<typename... T> struct hash_ops<std::tuple<T...>> { + static inline bool cmp(std::tuple<T...> a, std::tuple<T...> b) { + return a == b; + } + template<size_t I = 0> + static inline typename std::enable_if<I == sizeof...(T), unsigned int>::type hash(std::tuple<T...>) { + return mkhash_init; + } + template<size_t I = 0> + static inline typename std::enable_if<I != sizeof...(T), unsigned int>::type hash(std::tuple<T...> a) { + hash_ops<typename std::tuple_element<I, std::tuple<T...>>::type> element_ops; + return mkhash(hash<I+1>(a), element_ops.hash(std::get<I>(a))); + } +}; + template<typename T> struct hash_ops<std::vector<T>> { static inline bool cmp(std::vector<T> a, std::vector<T> b) { return a == b; |