From bce2f81d2f74ecd919704d43fb0c0f5499d50254 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 19 Dec 2014 15:00:33 +1100 Subject: [PATCH] point: add trivial std::hash specialisation --- point.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/point.hpp b/point.hpp index b9553d8e..2e3693b6 100644 --- a/point.hpp +++ b/point.hpp @@ -82,6 +82,24 @@ namespace util { typedef point<2,size_t> point2u; } +#include + +namespace std { + template <> + template + struct hash> { + size_t operator() (const util::point &p) const { + std::hash 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