summaryrefslogtreecommitdiff
path: root/lib/include/array_hash.hpp
blob: fd0d0f7aa894283338c04f8c5942c214f47fdf74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#pragma once

#include <array>
#include <unordered_map>

namespace std {
template <typename T, size_t N> struct hash<array<T, N>> {
  typedef array<T, N> argument_type;
  typedef size_t result_type;

  result_type operator()(const argument_type& a) const {
    hash<T> hasher;
    result_type h = 0;
    for (result_type i = 0; i < N; ++i) {
      h = h * 31 + hasher(a[i]);
    }
    return h;
  }
};
} // namespace std