From 71da9dda4df88ddec1f7e269d02b676aea7d1d02 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 15 Jun 2026 00:25:51 +0200 Subject: [PATCH] Core/Utils: Fix HashFnv1a compile error when hashing uint64 values with 32 bit variant at compile time --- src/common/Utilities/Hash.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/Utilities/Hash.h b/src/common/Utilities/Hash.h index 038906c453..b211c69d28 100644 --- a/src/common/Utilities/Hash.h +++ b/src/common/Utilities/Hash.h @@ -90,11 +90,13 @@ namespace Trinity { static_assert(std::is_integral_v || std::is_enum_v, "Only integral types can be hashed at compile time"); + using I = typename std::conditional_t, std::underlying_type, std::type_identity>::type; + for (V c : data) { for (std::size_t i = 0; i < sizeof(V); ++i) { - hash ^= (static_cast(c) >> (i * 8)) & 0xFF; + hash ^= static_cast((static_cast(c) >> (i * 8)) & 0xFF); hash *= Constants::Prime; } } @@ -127,7 +129,7 @@ namespace Trinity } template - inline static constexpr std::size_t GetHash(std::span data) noexcept + inline static constexpr T GetHash(std::span data) noexcept { HashFnv1a hash; hash.UpdateData(data); @@ -135,13 +137,13 @@ namespace Trinity } template - inline static constexpr std::size_t GetHash(V data) noexcept + inline static constexpr T GetHash(V data) noexcept { return HashFnv1a::GetHash(std::span(&data, 1)); } template - inline static constexpr std::size_t GetHash(V const& data) noexcept requires requires { std::span(data); } + inline static constexpr T GetHash(V const& data) noexcept requires requires { std::span(data); } { return HashFnv1a::GetHash(std::span(data)); }