From 3f44c1947ffb7b09559bcb7fc2019533200150d6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 9 Apr 2024 14:49:54 +0200 Subject: wa --- serialize/savegame.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'serialize/savegame.cpp') diff --git a/serialize/savegame.cpp b/serialize/savegame.cpp index 7b80c6fc..97fb61d4 100644 --- a/serialize/savegame.cpp +++ b/serialize/savegame.cpp @@ -61,6 +61,7 @@ struct string_hasher } }; +template concept Number = std::is_arithmetic_v>; template concept Enum = std::is_enum_v>; template concept Vector = Math::IsVector>::value; @@ -71,7 +72,7 @@ template [[maybe_unused]] T& non_const(const T&& value) = delete; template [[maybe_unused]] T& non_const_(const T& value) { return const_cast(value); } template [[maybe_unused]] T& non_const_(T& value) { return value; } -template [[maybe_unused]] T& non_const_(T&& value) { return value; } +template [[maybe_unused]] T& non_const_(T&& value) { return static_cast(value); } template [[maybe_unused]] T& non_const_(const T&& value) { return static_cast(const_cast(value)); } struct buffer @@ -149,7 +150,7 @@ struct visitor_ Derived& self = static_cast(*this); - template + template requires std::is_arithmetic_v> static void visit(T&& x, F&& f) { @@ -161,13 +162,14 @@ struct visitor_ { constexpr auto N = std::remove_cvref_t::Size; for (uint32_t i = 0; i < N; i++) - visit(forward(x).data()[i], f); + f(forward(x).data()[i]); } template void visit(E&& x, F&& f) { - visit(forward(x), f); + using U = std::underlying_type_t>; + f(non_const_(U(x))); } template -- cgit v1.2.3