From b749ef5f563fa9d099b158c2e493e8734558a327 Mon Sep 17 00:00:00 2001 From: gatecat Date: Thu, 7 Oct 2021 16:55:20 +0100 Subject: hashlib: Support for std::array keys Signed-off-by: gatecat --- common/hashlib.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'common/hashlib.h') diff --git a/common/hashlib.h b/common/hashlib.h index 063df78f..b71f0129 100644 --- a/common/hashlib.h +++ b/common/hashlib.h @@ -13,6 +13,7 @@ #define HASHLIB_H #include +#include #include #include #include @@ -132,6 +133,18 @@ template struct hash_ops> } }; +template struct hash_ops> +{ + static inline bool cmp(std::array a, std::array b) { return a == b; } + static inline unsigned int hash(std::array a) + { + unsigned int h = mkhash_init; + for (auto k : a) + h = mkhash(h, hash_ops::hash(k)); + return h; + } +}; + struct hash_cstr_ops { static inline bool cmp(const char *a, const char *b) -- cgit v1.2.3