Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Are there no specializations of std::hash for standard containers?
- std::unordered_set<std::array<int, 16> > test;
- 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;
- }
- };
- }
- template <> struct hash<bool>;
- template <> struct hash<char>;
- template <> struct hash<signed char>;
- template <> struct hash<unsigned char>;
- template <> struct hash<char16_t>;
- template <> struct hash<char32_t>;
- template <> struct hash<wchar_t>;
- template <> struct hash<short>;
- template <> struct hash<unsigned short>;
- template <> struct hash<int>;
- template <> struct hash<unsigned int>;
- template <> struct hash<long>;
- template <> struct hash<long long>;
- template <> struct hash<unsigned long>;
- template <> struct hash<unsigned long long>;
- template <> struct hash<float>;
- template <> struct hash<double>;
- template <> struct hash<long double>;
- template<class T> struct hash<T*>;
Add Comment
Please, Sign In to add comment