point: add trivial std::hash specialisation
This commit is contained in:
parent
a248d14d54
commit
bce2f81d2f
18
point.hpp
18
point.hpp
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user