diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index e0ac1d68d..49890b06f 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -8,6 +8,7 @@ #define NAZARA_VECTOR2_HPP #include +#include namespace Nz { @@ -119,6 +120,11 @@ template std::ostream& operator<<(std::ostream& out, const Nz::Vecto template Nz::Vector2 operator*(T scale, const Nz::Vector2& vec); template Nz::Vector2 operator/(T scale, const Nz::Vector2& vec); +namespace std +{ + template struct hash>; +} + #include #endif // NAZARA_VECTOR2_HPP diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 80e588ba4..8ca023843 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -1057,6 +1057,29 @@ Nz::Vector2 operator/(T scale, const Nz::Vector2& vec) return Nz::Vector2(scale / vec.x, scale / vec.y); } +namespace std +{ + template + struct hash> + { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param v Vector2 to hash + */ + std::size_t operator()(const Nz::Vector2& v) const + { + std::size_t seed {}; + + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + + return seed; + } + }; +} + #undef F #include diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 4e6da14ec..27681683f 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -8,6 +8,7 @@ #define NAZARA_VECTOR3_HPP #include +#include namespace Nz { @@ -141,6 +142,11 @@ template std::ostream& operator<<(std::ostream& out, const Nz::Vecto template Nz::Vector3 operator*(T scale, const Nz::Vector3& vec); template Nz::Vector3 operator/(T scale, const Nz::Vector3& vec); +namespace std +{ + template struct hash>; +} + #include #endif // NAZARA_VECTOR3_HPP diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index c5a0155c7..555286024 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -1347,6 +1347,31 @@ Nz::Vector3 operator/(T scale, const Nz::Vector3& vec) return Nz::Vector3(scale / vec.x, scale / vec.y, scale / vec.z); } +namespace std +{ + template + struct hash> + { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param v Vector3 to hash + */ + + std::size_t operator()(const Nz::Vector3& v) const + { + std::size_t seed {}; + + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.z); + + return seed; + } + }; +} + #undef F #include diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 0f8e907fc..d878c2ea5 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -8,6 +8,7 @@ #define NAZARA_VECTOR4_HPP #include +#include namespace Nz { @@ -117,6 +118,11 @@ template std::ostream& operator<<(std::ostream& out, const Nz::Vecto template Nz::Vector4 operator*(T scale, const Nz::Vector4& vec); template Nz::Vector4 operator/(T scale, const Nz::Vector4& vec); +namespace std +{ + template struct hash>; +} + #include #endif // NAZARA_VECTOR4_HPP diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 73a9a0802..190d31b99 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -1120,6 +1120,31 @@ Nz::Vector4 operator/(T scale, const Nz::Vector4& vec) return Nz::Vector4(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w); } +namespace std +{ + template + struct hash> + { + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param v Vector4 to hash + */ + std::size_t operator()(const Nz::Vector4& v) const + { + std::size_t seed {}; + + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.z); + Nz::HashCombine(seed, v.w); + + return seed; + } + }; +} + #undef F #include