point: add trivial std::hash specialisation

This commit is contained in:
Danny Robson 2014-12-19 15:00:33 +11:00
parent a248d14d54
commit bce2f81d2f

View File

@ -82,6 +82,24 @@ namespace util {
typedef point<2,size_t> point2u;
}
#include <functional>
namespace std {
template <>
template <size_t S, typename T>
struct hash<util::point<S,T>> {
size_t operator() (const util::point<S,T> &p) const {
std::hash<T> h;
size_t k = 0;
for (size_t i = 0; i < S; ++i)
k = h (p.data[i] ^ k);
return k;
}
};
}
#include "point.ipp"
#endif // __UTIL_POINT_HPP