From 22952237dfc2bd8b1daa6650f1c5cf7b141b477b Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Sat, 28 Dec 2024 09:36:20 +0800 Subject: [PATCH] fix(templates): fix the return value type of TTuple::Visit --- .../Source/Private/Testing/Strings.cpp | 8 ++++---- Redcraft.Utility/Source/Public/Templates/Tuple.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Redcraft.Utility/Source/Private/Testing/Strings.cpp b/Redcraft.Utility/Source/Private/Testing/Strings.cpp index d735cce..8c91c3b 100644 --- a/Redcraft.Utility/Source/Private/Testing/Strings.cpp +++ b/Redcraft.Utility/Source/Private/Testing/Strings.cpp @@ -543,10 +543,10 @@ void TestConvert() } { - always_check(LITERAL_VIEW(T, "42" ).ToInt() == 42 ); - always_check(LITERAL_VIEW(T, "FF" ).ToInt(16) == 255); - always_check(LITERAL_VIEW(T, "-42" ).ToInt() == -42); - always_check(LITERAL_VIEW(T, "0" ).ToInt() == 0 ); + always_check(LITERAL_VIEW(T, "42" ).ToInt() == 42 ); + always_check(LITERAL_VIEW(T, "FF" ).ToInt(16) == 255); + always_check(LITERAL_VIEW(T, "-42").ToInt() == -42); + always_check(LITERAL_VIEW(T, "0" ).ToInt() == 0 ); } { diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 2246203..5e38496 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -441,14 +441,14 @@ public: template requires (true && ... && CInvocable) FORCEINLINE constexpr void Visit(F&& Func) const volatile&& { VisitTuple(Forward(Func), static_cast(*this)); } /** Visits specified element in a tuple and applies it as arguments to the function. */ - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) & { return static_cast< TTuple& >(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const & { return static_cast(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) volatile& { return static_cast< volatile TTuple& >(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const volatile& { return static_cast(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) && { return static_cast< TTuple&&>(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const && { return static_cast(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) volatile&& { return static_cast< volatile TTuple&&>(*this).Visit...>>(Forward(Func), Index); } - template requires ((sizeof...(Ts) >= 1 && CCommonType...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const volatile&& { return static_cast(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) & { return static_cast< TTuple& >(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const & { return static_cast(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) volatile& { return static_cast< volatile TTuple& >(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const volatile& { return static_cast(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) && { return static_cast< TTuple&&>(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const && { return static_cast(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) volatile&& { return static_cast< volatile TTuple&&>(*this).Visit...>>(Forward(Func), Index); } + template requires ((sizeof...(Ts) >= 1 && CCommonReference...>) && ... && (CInvocable)) FORCEINLINE constexpr decltype(auto) Visit(F&& Func, size_t Index) const volatile&& { return static_cast(*this).Visit...>>(Forward(Func), Index); } /** Visits specified element in a tuple and applies it as arguments to the function. */ template requires ((sizeof...(Ts) >= 1) && ... && CInvocableResult) FORCEINLINE constexpr Ret Visit(F&& Func, size_t Index) & { return NAMESPACE_PRIVATE::TTupleVisitElementByIndex>::Do(Forward(Func), static_cast< TTuple& >(*this), Index); }