単純に使用できないことに少し驚いた
std::unordered_set<std::array<int, 16> > test;
std::hash
sの専門分野がないように思われるからですstd::array
。何故ですか?それとも私は単にそれを見つけられませんでしたか?実際に何もない場合、次の実装の試みを簡略化できますか?
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;
}
};
}
これはどういうわけか標準ライブラリの一部であるべきだと私は本当に感じています。