diff --git a/include/vector2d.h b/include/vector2d.h index 08672a38..a0eb7ea8 100644 --- a/include/vector2d.h +++ b/include/vector2d.h @@ -8,6 +8,8 @@ #include "irrMath.h" #include "dimension2d.h" +#include + namespace irr { namespace core @@ -414,5 +416,21 @@ public: } // end namespace core } // end namespace irr +namespace std +{ + +template +struct hash > +{ + size_t operator()(const irr::core::vector2d& vec) const + { + size_t h1 = hash()(vec.X); + size_t h2 = hash()(vec.Y); + return (h1 << (4 * sizeof(h1)) | h1 >> (4 * sizeof(h1))) ^ h2; + } +}; + +} + #endif diff --git a/include/vector3d.h b/include/vector3d.h index 4dbc53b8..ed910e9f 100644 --- a/include/vector3d.h +++ b/include/vector3d.h @@ -7,6 +7,8 @@ #include "irrMath.h" +#include + namespace irr { namespace core @@ -466,5 +468,22 @@ namespace core } // end namespace core } // end namespace irr +namespace std +{ + +template +struct hash > +{ + size_t operator()(const irr::core::vector3d& vec) const + { + size_t h1 = hash()(vec.X); + size_t h2 = hash()(vec.Y); + size_t h3 = hash()(vec.Z); + return (h1 << (5 * sizeof(h1)) | h1 >> (3 * sizeof(h1))) ^ (h2 << (2 * sizeof(h2)) | h2 >> (6 * sizeof(h2))) ^ h3; + } +}; + +} + #endif