aboutsummaryrefslogtreecommitdiff
path: root/include/vector2d.h
diff options
context:
space:
mode:
authorRichard Try <bazrovstepan@gmail.com>2022-05-10 20:26:24 +0300
committerGitHub <noreply@github.com>2022-05-10 19:26:24 +0200
commit6928c7eb6f00a00df4efcf1a1ec8f2310609696b (patch)
tree18e265d0921511b2ab542f37dc217573008e5b9c /include/vector2d.h
parent372b3642bf524da2694cc09bdc8bdacb23f5fd0e (diff)
downloadirrlicht-6928c7eb6f00a00df4efcf1a1ec8f2310609696b.tar.xz
Add hash for vector2d and vector3d (#93)
Diffstat (limited to 'include/vector2d.h')
-rw-r--r--include/vector2d.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/vector2d.h b/include/vector2d.h
index 08672a3..a0eb7ea 100644
--- a/include/vector2d.h
+++ b/include/vector2d.h
@@ -8,6 +8,8 @@
#include "irrMath.h"
#include "dimension2d.h"
+#include <functional>
+
namespace irr
{
namespace core
@@ -414,5 +416,21 @@ public:
} // end namespace core
} // end namespace irr
+namespace std
+{
+
+template<class T>
+struct hash<irr::core::vector2d<T> >
+{
+ size_t operator()(const irr::core::vector2d<T>& vec) const
+ {
+ size_t h1 = hash<T>()(vec.X);
+ size_t h2 = hash<T>()(vec.Y);
+ return (h1 << (4 * sizeof(h1)) | h1 >> (4 * sizeof(h1))) ^ h2;
+ }
+};
+
+}
+
#endif