aboutsummaryrefslogtreecommitdiffstats
path: root/common/hashlib.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/hashlib.h')
-rw-r--r--common/hashlib.h13
1 files changed, 13 insertions, 0 deletions
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 <algorithm>
+#include <array>
#include <stdexcept>
#include <string>
#include <vector>
@@ -132,6 +133,18 @@ template <typename T> struct hash_ops<std::vector<T>>
}
};
+template <typename T, size_t N> struct hash_ops<std::array<T, N>>
+{
+ static inline bool cmp(std::array<T, N> a, std::array<T, N> b) { return a == b; }
+ static inline unsigned int hash(std::array<T, N> a)
+ {
+ unsigned int h = mkhash_init;
+ for (auto k : a)
+ h = mkhash(h, hash_ops<T>::hash(k));
+ return h;
+ }
+};
+
struct hash_cstr_ops
{
static inline bool cmp(const char *a, const char *b)