Commit 3985ae7 1 parent e36eaa5 commit 3985ae7 Copy full SHA for 3985ae7
File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,25 @@ inline unsigned int mkhash(const T &v) {
186
186
return hash_ops<T>().hash (v);
187
187
}
188
188
189
+ template <> struct hash_ops <std::monostate> {
190
+ static inline bool cmp (std::monostate a, std::monostate b) {
191
+ return a == b;
192
+ }
193
+ static inline unsigned int hash (std::monostate) {
194
+ return mkhash_init;
195
+ }
196
+ };
197
+
198
+ template <typename ... T> struct hash_ops <std::variant<T...>> {
199
+ static inline bool cmp (std::variant<T...> a, std::variant<T...> b) {
200
+ return a == b;
201
+ }
202
+ static inline unsigned int hash (std::variant<T...> a) {
203
+ unsigned int h = std::visit ([](const auto &v) { return mkhash (v); }, a);
204
+ return mkhash (a.index (), h);
205
+ }
206
+ };
207
+
189
208
inline int hashtable_size (int min_size)
190
209
{
191
210
static std::vector<int > zero_and_some_primes = {
Original file line number Diff line number Diff line change 30
30
#include < unordered_map>
31
31
#include < unordered_set>
32
32
#include < initializer_list>
33
+ #include < variant>
33
34
#include < stdexcept>
34
35
#include < memory>
35
36
#include < cmath>
You can’t perform that action at this time.
0 commit comments