From 59b2e55ed5a71fdcbe7ecdd66b80b72b9e4346fd Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 17:56:46 +0200 Subject: [PATCH 1/8] Added hash for Vectors --- include/Nazara/Math/Vector2.hpp | 9 +++++++++ include/Nazara/Math/Vector2.inl | 24 ++++++++++++++++++++++++ include/Nazara/Math/Vector3.hpp | 9 +++++++++ include/Nazara/Math/Vector3.inl | 25 +++++++++++++++++++++++++ include/Nazara/Math/Vector4.hpp | 9 +++++++++ include/Nazara/Math/Vector4.inl | 26 ++++++++++++++++++++++++++ 6 files changed, 102 insertions(+) diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index e0ac1d68d..d3e8be8c5 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,14 @@ 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..c602052f3 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -1057,6 +1057,30 @@ 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..cff16be55 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,14 @@ 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..41bd20400 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..0c408b90e 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,14 @@ 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..05a28532b 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -1120,6 +1120,32 @@ 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 From d69166991a4a7c294ac0c28f177ea9f70f212539 Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 18:11:51 +0200 Subject: [PATCH 2/8] Fixing an oopsie (1) --- include/Nazara/Math/Vector4.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 0c408b90e..8ac50c8cb 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -122,7 +122,7 @@ namespace std { template -struct hash>; +struct hash>; } From e1d948c34881c8402e05f78440d591feb1a38da5 Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 18:11:56 +0200 Subject: [PATCH 3/8] Fixing an oopsie (2) --- include/Nazara/Math/Vector3.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index cff16be55..2725fcc45 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -146,7 +146,7 @@ namespace std { template -struct hash>; +struct hash>; } From 255b1cce07da1643c55339293feb409cba55ef10 Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 18:22:53 +0200 Subject: [PATCH 4/8] Fix + indent --- include/Nazara/Math/Vector2.inl | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index c602052f3..19313c3e4 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -1063,24 +1063,26 @@ namespace std template struct hash> { - /*! - * \brief Specialisation of std to hash - * \return Result of the hash - * - * \param v Vector2 to 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 {}; + std::size_t operator()(const Nz::Vector2& v) const + { + std::size_t seed {}; - Nz::HashCombine(seed, v.x); - Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); - return seed; - } + return seed; + } }; +} + #undef F #include From c5c4ef2c09dee1c6e731d17bfa4cb239176577d0 Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 18:22:57 +0200 Subject: [PATCH 5/8] Fix + indent, again --- include/Nazara/Math/Vector3.inl | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 41bd20400..0a67aea74 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -1353,25 +1353,27 @@ namespace std template struct hash> { - /*! - * \brief Specialisation of std to hash - * \return Result of the hash - * - * \param v Vector3 to 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 {}; + 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); + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.z); - return seed; - } + return seed; + } }; +} + #undef F #include From e5300da9330e2e0375fafe6a9ce55c4c684221a8 Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 18:23:28 +0200 Subject: [PATCH 6/8] Same --- include/Nazara/Math/Vector4.inl | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 05a28532b..565b4c0c3 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -1107,7 +1107,7 @@ Nz::Vector4 operator*(T scale, const Nz::Vector4& vec) template Nz::Vector4 operator/(T scale, const Nz::Vector4& vec) { - #if NAZARA_MATH_SAFE + #if NAZARA_MATH_SAFE if (NumberEquals(vec.x, F(0.0)) || NumberEquals(vec.y, F(0.0)) || NumberEquals(vec.z, F(0.0)) || NumberEquals(vec.w, F(0.0))) { Nz::String error("Division by zero"); @@ -1126,26 +1126,28 @@ namespace std template struct hash> { - /*! - * \brief Specialisation of std to hash - * \return Result of the hash - * - * \param v Vector4 to 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 {}; + 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); + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.z); + Nz::HashCombine(seed, v.w); - return seed; - } + return seed; + } }; +} + #undef F #include From 5ea3eab8fc702c2693166fa89bb2012ed430cc24 Mon Sep 17 00:00:00 2001 From: S6066 Date: Wed, 12 Oct 2016 18:24:51 +0200 Subject: [PATCH 7/8] Oops, added an indent --- include/Nazara/Math/Vector4.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 565b4c0c3..94b46872d 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -1107,7 +1107,7 @@ Nz::Vector4 operator*(T scale, const Nz::Vector4& vec) template Nz::Vector4 operator/(T scale, const Nz::Vector4& vec) { - #if NAZARA_MATH_SAFE + #if NAZARA_MATH_SAFE if (NumberEquals(vec.x, F(0.0)) || NumberEquals(vec.y, F(0.0)) || NumberEquals(vec.z, F(0.0)) || NumberEquals(vec.w, F(0.0))) { Nz::String error("Division by zero"); From 5d5c7b42849b60c775309f6eae997a69f423332b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 13 Oct 2016 04:48:19 +0200 Subject: [PATCH 8/8] PR-82: Fix indent --- include/Nazara/Math/Vector2.hpp | 5 +---- include/Nazara/Math/Vector2.inl | 35 ++++++++++++++--------------- include/Nazara/Math/Vector3.hpp | 5 +---- include/Nazara/Math/Vector3.inl | 36 ++++++++++++++---------------- include/Nazara/Math/Vector4.hpp | 5 +---- include/Nazara/Math/Vector4.inl | 39 +++++++++++++++------------------ 6 files changed, 54 insertions(+), 71 deletions(-) diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index d3e8be8c5..49890b06f 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -122,10 +122,7 @@ template Nz::Vector2 operator/(T scale, const Nz::Vector2& vec namespace std { - -template -struct hash>; - + template struct hash>; } #include diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 19313c3e4..8ca023843 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -1059,28 +1059,25 @@ Nz::Vector2 operator/(T scale, const Nz::Vector2& vec) 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 + template + struct hash> { - std::size_t seed {}; + /*! + * \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; - } -}; + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + return seed; + } + }; } #undef F diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 2725fcc45..27681683f 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -144,10 +144,7 @@ template Nz::Vector3 operator/(T scale, const Nz::Vector3& vec namespace std { - -template -struct hash>; - + template struct hash>; } #include diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 0a67aea74..555286024 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -1349,29 +1349,27 @@ Nz::Vector3 operator/(T scale, const Nz::Vector3& vec) 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 + template + struct hash> { - std::size_t seed {}; + /*! + * \brief Specialisation of std to hash + * \return Result of the hash + * + * \param v Vector3 to hash + */ - Nz::HashCombine(seed, v.x); - Nz::HashCombine(seed, v.y); - Nz::HashCombine(seed, v.z); + std::size_t operator()(const Nz::Vector3& v) const + { + std::size_t seed {}; - return seed; - } -}; + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.z); + return seed; + } + }; } #undef F diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 8ac50c8cb..d878c2ea5 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -120,10 +120,7 @@ template Nz::Vector4 operator/(T scale, const Nz::Vector4& vec namespace std { - -template -struct hash>; - + template struct hash>; } #include diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 94b46872d..190d31b99 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -1122,30 +1122,27 @@ Nz::Vector4 operator/(T scale, const Nz::Vector4& vec) 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 + template + struct hash> { - std::size_t seed {}; + /*! + * \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; - } -}; + Nz::HashCombine(seed, v.x); + Nz::HashCombine(seed, v.y); + Nz::HashCombine(seed, v.z); + Nz::HashCombine(seed, v.w); + return seed; + } + }; } #undef F