From 21d6f96d3a55433e67348c140d421a3d67136d03 Mon Sep 17 00:00:00 2001 From: Emily Schmidt Date: Thu, 25 Jul 2024 12:25:19 +0100 Subject: [PATCH] add optional header and hashlib implementation for optional --- kernel/hashlib.h | 12 ++++++++++++ kernel/yosys_common.h | 1 + 2 files changed, 13 insertions(+) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 12349b21cfb..278832c008f 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -205,6 +205,18 @@ template struct hash_ops> { } }; +template struct hash_ops> { + static inline bool cmp(std::optional a, std::optional b) { + return a == b; + } + static inline unsigned int hash(std::optional a) { + if(a.has_value()) + return mkhash(*a); + else + return 0; + } +}; + inline int hashtable_size(int min_size) { static std::vector zero_and_some_primes = { diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index 4391ad582ee..86d448d211b 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include