diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index 0d71b0b..999dee3 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -895,76 +895,24 @@ void TestTuple() TTuple TempA = { MoveTemp(TempO), 514 }; TempA.Apply( - [] (T&& A, U&& B) + [](auto&& A, auto&& B) { always_check(A == 15); always_check(B == 514); - always_check((CSameAs)); - always_check((CSameAs)); + always_check((CSameAs)); + always_check((CSameAs)); } ); MoveTemp(TempA).Apply( - [] (T&& A, U&& B) + [](auto&& A, auto&& B) { always_check(A == 15); always_check(B == 514); - always_check((CSameAs)); - always_check((CSameAs)); + always_check((CSameAs)); + always_check((CSameAs)); } ); - - TempA.ApplyAfter( - [] (T&& A, U&& B, V&&C) - { - always_check(A == '-'); - always_check(B == 15); - always_check(C == 514); - always_check((CSameAs)); - always_check((CSameAs)); - always_check((CSameAs)); - }, - '-' - ); - - MoveTemp(TempA).ApplyAfter( - [] (T&& A, U&& B, V&&C) - { - always_check(A == '-'); - always_check(B == 15); - always_check(C == 514); - always_check((CSameAs)); - always_check((CSameAs)); - always_check((CSameAs)); - }, - '-' - ); - - TempA.ApplyBefore( - [] (T&& A, U&& B, V&&C) - { - always_check(A == 15); - always_check(B == 514); - always_check(C == '-'); - always_check((CSameAs)); - always_check((CSameAs)); - always_check((CSameAs)); - }, - '-' - ); - - MoveTemp(TempA).ApplyBefore( - [] (T&& A, U&& B, V&&C) - { - always_check(A == 15); - always_check(B == 514); - always_check(C == '-'); - always_check((CSameAs)); - always_check((CSameAs)); - always_check((CSameAs)); - }, - '-' - ); } { diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index a2bd017..47023aa 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -211,18 +211,6 @@ public: return Invoke(Forward(Func), Forward(Arg).template GetValue()...); } - template - static constexpr auto ApplyAfter(F&& Func, TTupleType&& Arg, ArgTypes&&... OtherArgs) - { - return Invoke(Forward(Func), Forward(OtherArgs)..., Forward(Arg).template GetValue()...); - } - - template - static constexpr auto ApplyBefore(F&& Func, TTupleType&& Arg, ArgTypes&&... OtherArgs) - { - return Invoke(Forward(Func), Forward(Arg).template GetValue()..., Forward(OtherArgs)...); - } - template static constexpr auto Transform(F&& Func, TTupleType&& Arg) { @@ -332,24 +320,6 @@ public: template requires (CInvocable) constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } template requires (CInvocable) constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } - template requires (CInvocable) constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } template requires (true && ... && (CInvocable && !CSameAs>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } @@ -441,7 +411,7 @@ struct TTupleCatMake, TIndexSequence> struct ForwardType { using Type = TConditional, TRemoveReference&&, U>; }; template - static constexpr TTuple F(TTupleType&& InValue) + static constexpr TTuple Do(TTupleType&& InValue) { return TTuple ( @@ -460,7 +430,7 @@ template struct TTupleCatForward, TIndexSequence> { template - static constexpr decltype(auto) F(ForwardType&& ForwardTuple, TTupleType&& InValue) + static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue) { return ForwardAsTuple(Forward(ForwardTuple).template GetValue()..., Forward(InValue).template GetValue()...); } @@ -470,18 +440,18 @@ template struct TTupleCatImpl { template - static constexpr decltype(auto) F(ForwardType&& ForwardTuple, TTupleType&& InValue, OtherTTupleTypes&&... OtherValue) + static constexpr decltype(auto) Do(ForwardType&& ForwardTuple, TTupleType&& InValue, OtherTTupleTypes&&... OtherValue) { - return F(TTupleCatForward< + return Do(TTupleCatForward< TMakeIndexSequence>>, TMakeIndexSequence>>> - ::F(Forward(ForwardTuple), Forward(InValue)), Forward(OtherValue)...); + ::Do(Forward(ForwardTuple), Forward(InValue)), Forward(OtherValue)...); } template - static constexpr decltype(auto) F(ForwardType&& ForwardTuple) + static constexpr decltype(auto) Do(ForwardType&& ForwardTuple) { - return TTupleCatMake>>::F(Forward(ForwardTuple)); + return TTupleCatMake>>::Do(Forward(ForwardTuple)); } }; @@ -492,11 +462,11 @@ template struct TTupleThreeWay> { template - static constexpr R F(const LHSTupleType& LHS, const RHSTupleType& RHS) + static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS) { auto Result = SynthThreeWayCompare(LHS.template GetValue(), RHS.template GetValue()); if (Result != 0) return Result; - return TTupleThreeWay>::F(LHS, RHS); + return TTupleThreeWay>::Do(LHS, RHS); } }; @@ -504,7 +474,7 @@ template struct TTupleThreeWay> { template - static constexpr R F(const LHSTupleType& LHS, const RHSTupleType& RHS) + static constexpr R Do(const LHSTupleType& LHS, const RHSTupleType& RHS) { return R::equivalent; } @@ -516,11 +486,11 @@ struct TTupleVisitImpl; template struct TTupleVisitImpl> { - template - static constexpr void F(G&& Func, TupleTypes&&... Tuples) + template + static constexpr void Do(F&& Func, TupleTypes&&... Tuples) { - Invoke(Forward(Func), Forward(Tuples).template GetValue()...); - TTupleVisitImpl>::F(Forward(Func), Forward(Tuples)...); + Invoke(Forward(Func), Forward(Tuples).template GetValue()...); + TTupleVisitImpl>::Do(Forward(Func), Forward(Tuples)...); } }; @@ -528,7 +498,7 @@ template <> struct TTupleVisitImpl> { template - static constexpr void F(TupleTypes&&... Tuples) { } + static constexpr void Do(TupleTypes&&... Tuples) { } }; NAMESPACE_PRIVATE_END @@ -541,7 +511,7 @@ constexpr decltype(auto) TupleCat(TTupleTypes&&... Args) { using R = TTupleCatResult; if constexpr (sizeof...(Args) == 0) return R(); - else return NAMESPACE_PRIVATE::TTupleCatImpl::F(Forward(Args)...); + else return NAMESPACE_PRIVATE::TTupleCatImpl::Do(Forward(Args)...); } template requires (sizeof...(LHSTypes) != sizeof...(RHSTypes) || (true && ... && CWeaklyEqualityComparable)) @@ -555,17 +525,15 @@ template requires (sizeof...(LHSTyp constexpr TCommonComparisonCategory...> operator<=>(const TTuple& LHS, const TTuple& RHS) { using R = TCommonComparisonCategory...>; - return NAMESPACE_PRIVATE::TTupleThreeWay>::F(LHS, RHS); + return NAMESPACE_PRIVATE::TTupleThreeWay>::Do(LHS, RHS); } -template -constexpr void VisitTuple(F&& Func) { } - -template requires (CTTuple> && (true && ... && CTTuple>)) +template + requires (CTTuple> && (true && ... && CTTuple>)) constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&... Tuples) { NAMESPACE_PRIVATE::TTupleVisitImpl>>> - ::F(Forward(Func), Forward(FirstTuple), Forward(Tuples)...); + ::Do(Forward(Func), Forward(FirstTuple), Forward(Tuples)...); } template requires (requires { typename TTuple...>; })