diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 6b880f3a6..d32db6832 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -186,6 +186,25 @@ inline unsigned int mkhash(const T &v) { return hash_ops().hash(v); } +template<> struct hash_ops { + static inline bool cmp(std::monostate a, std::monostate b) { + return a == b; + } + static inline unsigned int hash(std::monostate) { + return mkhash_init; + } +}; + +template struct hash_ops> { + static inline bool cmp(std::variant a, std::variant b) { + return a == b; + } + static inline unsigned int hash(std::variant a) { + unsigned int h = std::visit([](const auto &v) { return mkhash(v); }, a); + return mkhash(a.index(), h); + } +}; + inline int hashtable_size(int min_size) { // Primes as generated by https://oeis.org/A175953 diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index 56d2356b1..e71e94a78 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include