From a546c1a6d1eb655f1768bf85ac09f45a5f108723 Mon Sep 17 00:00:00 2001 From: va_alpatov Date: Fri, 19 Jun 2026 01:01:27 +0300 Subject: [PATCH] added template hash --- include/omath/linear_algebra/vector2.hpp | 7 ++++--- include/omath/linear_algebra/vector3.hpp | 7 ++++--- include/omath/linear_algebra/vector4.hpp | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/omath/linear_algebra/vector2.hpp b/include/omath/linear_algebra/vector2.hpp index a4f23de..ae80bce 100644 --- a/include/omath/linear_algebra/vector2.hpp +++ b/include/omath/linear_algebra/vector2.hpp @@ -265,13 +265,14 @@ namespace omath }; } // namespace omath -template<> struct std::hash> +template +struct std::hash> // NOLINT(*-dcl58-cpp) { [[nodiscard("You must use hash value")]] - std::size_t operator()(const omath::Vector2& vec) const noexcept + std::size_t operator()(const omath::Vector2& vec) const noexcept { std::size_t hash = 0; - constexpr std::hash hasher; + constexpr std::hash hasher; hash ^= hasher(vec.x) + 0x9e3779b9 + (hash << 6) + (hash >> 2); hash ^= hasher(vec.y) + 0x9e3779b9 + (hash << 6) + (hash >> 2); diff --git a/include/omath/linear_algebra/vector3.hpp b/include/omath/linear_algebra/vector3.hpp index b607a4f..1fa6c27 100644 --- a/include/omath/linear_algebra/vector3.hpp +++ b/include/omath/linear_algebra/vector3.hpp @@ -318,14 +318,15 @@ namespace omath }; } // namespace omath -template<> struct std::hash> +template +struct std::hash> // NOLINT(*-dcl58-cpp) { // NOTE: Cannot be constexpr because of MSVC [[nodiscard("You must use hash value")]] - std::size_t operator()(const omath::Vector3& vec) const noexcept + std::size_t operator()(const omath::Vector3& vec) const noexcept { std::size_t hash = 0; - constexpr std::hash hasher; + constexpr std::hash hasher; hash ^= hasher(vec.x) + 0x9e3779b9 + (hash << 6) + (hash >> 2); hash ^= hasher(vec.y) + 0x9e3779b9 + (hash << 6) + (hash >> 2); diff --git a/include/omath/linear_algebra/vector4.hpp b/include/omath/linear_algebra/vector4.hpp index 576656c..2044acf 100644 --- a/include/omath/linear_algebra/vector4.hpp +++ b/include/omath/linear_algebra/vector4.hpp @@ -225,13 +225,14 @@ namespace omath }; } // namespace omath -template<> struct std::hash> +template +struct std::hash> // NOLINT(*-dcl58-cpp) { [[nodiscard("You must use hash value")]] - std::size_t operator()(const omath::Vector4& vec) const noexcept + std::size_t operator()(const omath::Vector4& vec) const noexcept { std::size_t hash = 0; - constexpr std::hash hasher; + constexpr std::hash hasher; hash ^= hasher(vec.x) + 0x9e3779b9 + (hash << 6) + (hash >> 2); hash ^= hasher(vec.y) + 0x9e3779b9 + (hash << 6) + (hash >> 2); @@ -240,7 +241,6 @@ template<> struct std::hash> return hash; } }; - template struct std::formatter> // NOLINT(*-dcl58-cpp) {