diff --git a/Redcraft.Utility/Source/Private/Testing/ConceptsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/ConceptsTesting.cpp index 1011168..0583c98 100644 --- a/Redcraft.Utility/Source/Private/Testing/ConceptsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/ConceptsTesting.cpp @@ -53,32 +53,12 @@ NAMESPACE_UNNAMED_END void TestConcepts() { - // Same.h - - always_check(!(CSameAs)); - always_check((CSameAs)); - // Derived.h always_check(!(CDerivedFrom)); always_check((CDerivedFrom)); always_check(!(CDerivedFrom)); - // Convertible.h - - always_check((CConvertibleTo)); - always_check(!(CConvertibleTo)); - always_check((CConvertibleTo)); - always_check(!(CConvertibleTo)); - always_check((CConvertibleTo)); - - // BooleanTestable.h - - always_check(CBooleanTestable); - always_check(CBooleanTestable); - always_check(CBooleanTestable); - always_check(!CBooleanTestable); - // Common.h always_check((CCommonWith)); @@ -133,15 +113,6 @@ void TestConcepts() always_check((CSwappableWith)); - // Invocable.h - - always_check((CInvocable void { }) >)); - always_check((CRegularInvocable int32 { return A; }), int32 >)); - always_check((CPredicate bool { return (A + B + C) == 0; }), int32, int32, int32 >)); - always_check((CRelation bool { return (A ^ B) == 0; }), int32, int32 >)); - always_check((CEquivalenceRelation bool { return A == B; }), int32, int32 >)); - always_check((CStrictWeakOrder bool { return A < B; }), int32, int32 >)); - } NAMESPACE_END(Testing) diff --git a/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp b/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp index a0dc7cf..03b8df1 100644 --- a/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp @@ -185,9 +185,9 @@ void TestCompare() always_check((FTestStrongOrdering( 0) == FTestStrongOrdering( 0))); always_check((FTestStrongOrdering( 0) > FTestStrongOrdering(-1))); - always_check((TIsSame::Type, strong_ordering >::Value)); - always_check((TIsSame::Type, weak_ordering >::Value)); - always_check((TIsSame::Type, partial_ordering>::Value)); + always_check((CSameAs::Type, strong_ordering >)); + always_check((CSameAs::Type, weak_ordering >)); + always_check((CSameAs::Type, partial_ordering>)); always_check(CThreeWayComparable); always_check(CThreeWayComparable); @@ -197,11 +197,11 @@ void TestCompare() always_check((CThreeWayComparableWith)); always_check((CThreeWayComparableWith)); - always_check((TIsSame::Type, strong_ordering >::Value)); - always_check((TIsSame::Type, partial_ordering>::Value)); - always_check((TIsSame::Type, partial_ordering>::Value)); - always_check((TIsSame::Type, weak_ordering >::Value)); - always_check((TIsSame::Type, strong_ordering >::Value)); + always_check((CSameAs::Type, strong_ordering >)); + always_check((CSameAs::Type, partial_ordering>)); + always_check((CSameAs::Type, partial_ordering>)); + always_check((CSameAs::Type, weak_ordering >)); + always_check((CSameAs::Type, strong_ordering >)); always_check((SynthThreeWayCompare(0, 0) == strong_ordering::equal)); always_check((SynthThreeWayCompare(0, 0.0) == strong_ordering::equal)); diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index 4ece624..5b52360 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -79,8 +79,8 @@ void TestReferenceWrapper() always_check(ArrayA[1] == 4); always_check(ArrayA[2] == 6); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame>::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs>::Type>)); } void TestOptional() @@ -255,9 +255,9 @@ void TestVariant() TempZ = TVariant(); TempZ = FTracker(); - always_check((TIsSame>::Type>::Value)); - always_check((TIsSame>::Type>::Value)); - always_check((TIsSame>::Type>::Value)); + always_check((CSameAs>::Type>)); + always_check((CSameAs>::Type>)); + always_check((CSameAs>::Type>)); always_check((TVariantAlternativeIndex>::Value == 0)); always_check((TVariantAlternativeIndex>::Value == 1)); @@ -282,7 +282,7 @@ void TestVariant() TVariant TempLA = 10; auto ReturnLA = TempLA.Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = true; bIsLValue = true; @@ -290,7 +290,7 @@ void TestVariant() const TVariant TempLB = TempLA; auto ReturnLB = TempLB.Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = false; bIsLValue = false; @@ -298,7 +298,7 @@ void TestVariant() TVariant TempRA = 10; auto ReturnRA = MoveTemp(TempRA).Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = true; bIsLValue = false; @@ -306,7 +306,7 @@ void TestVariant() const TVariant TempRB = TempLA; auto ReturnRB = MoveTemp(TempRB).Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = false; bIsLValue = true; @@ -314,7 +314,7 @@ void TestVariant() TVariant TempLC = 10; auto ReturnLC = TempLC.Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = true; bIsLValue = true; @@ -322,7 +322,7 @@ void TestVariant() const TVariant TempLD = TempLC; auto ReturnLD = TempLD.Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = false; bIsLValue = false; @@ -330,7 +330,7 @@ void TestVariant() TVariant TempRC = 10; auto ReturnRC = MoveTemp(TempRC).Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); bIsConst = true; bIsLValue = false; @@ -338,7 +338,7 @@ void TestVariant() const TVariant TempRD = TempLC; auto ReturnRD = MoveTemp(TempRD).Visit(TestQualifiers); - always_check((TIsSame::Value)); + always_check((CSameAs)); } { @@ -584,120 +584,120 @@ void TestAny() void TestTuple() { - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); - always_check((TIsSame&&>().GetValue<0>()), int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); + always_check((CSameAs&&>().GetValue<0>()), int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); - always_check((TIsSame&&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&>::Value)); + always_check((CSameAs&&>().GetValue<0>()), int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&>)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), volatile int32&>::Value)); - always_check((TIsSame&>().GetValue<0>()), const volatile int32&>::Value)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), int32&>)); + always_check((CSameAs&>().GetValue<0>()), const int32&>)); + always_check((CSameAs&>().GetValue<0>()), volatile int32&>)); + always_check((CSameAs&>().GetValue<0>()), const volatile int32&>)); - always_check((TIsSame&&>().GetValue<0>()), int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), volatile int32&&>::Value)); - always_check((TIsSame&&>().GetValue<0>()), const volatile int32&&>::Value)); + always_check((CSameAs&&>().GetValue<0>()), int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), volatile int32&&>)); + always_check((CSameAs&&>().GetValue<0>()), const volatile int32&&>)); - always_check((TIsSame>::Type, double>::Value)); - always_check((TIsSame>::Type, float&>::Value)); - always_check((TIsSame>::Type, char&&>::Value)); - always_check((TIsSame>::Type, const double>::Value)); - always_check((TIsSame>::Type, const float&>::Value)); - always_check((TIsSame>::Type, const char&&>::Value)); - always_check((TIsSame>::Type, volatile double>::Value)); - always_check((TIsSame>::Type, volatile float&>::Value)); - always_check((TIsSame>::Type, volatile char&&>::Value)); - always_check((TIsSame>::Type, const volatile double>::Value)); - always_check((TIsSame>::Type, const volatile float&>::Value)); - always_check((TIsSame>::Type, const volatile char&&>::Value)); + always_check((CSameAs>::Type, double>)); + always_check((CSameAs>::Type, float&>)); + always_check((CSameAs>::Type, char&&>)); + always_check((CSameAs>::Type, const double>)); + always_check((CSameAs>::Type, const float&>)); + always_check((CSameAs>::Type, const char&&>)); + always_check((CSameAs>::Type, volatile double>)); + always_check((CSameAs>::Type, volatile float&>)); + always_check((CSameAs>::Type, volatile char&&>)); + always_check((CSameAs>::Type, const volatile double>)); + always_check((CSameAs>::Type, const volatile float&>)); + always_check((CSameAs>::Type, const volatile char&&>)); always_check((TTupleElementIndex>::Value == 0)); always_check((TTupleElementIndex>::Value == 1)); @@ -714,11 +714,11 @@ void TestTuple() always_check((TTupleElementIndex>::Value == INDEX_NONE)); -// always_check((TIsSame::Type, double>::Value)); +// always_check((CSameAs::Type, double>)); // always_check((TTupleElementIndex::Value == 0)); -// always_check((TIsSame>::Type, double>::Value)); +// always_check((CSameAs>::Type, double>)); { using Type = TTuple() == 404); always_check(TempE.GetValue() == 3.14); always_check(TempE.GetValue() == 1.42f); - always_check((TIsSame>::Value)); - always_check((TIsSame, TTuple, TTuple>::Type>::Value)); + always_check((CSameAs>)); + always_check((CSameAs, TTuple, TTuple>::Type>)); } { @@ -826,8 +826,8 @@ void TestTuple() always_check(TempB == 3.14); always_check(TempG.GetValue<0>() == 10); always_check(TempG.GetValue<2>() == 10); - always_check((TIsSame>::Value)); - always_check((TIsSame, TTuple>::Type>::Value)); + always_check((CSameAs>)); + always_check((CSameAs, TTuple>::Type>)); } { @@ -839,8 +839,8 @@ void TestTuple() { always_check(A == 15); always_check(B == 514); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); + always_check((CSameAs)); + always_check((CSameAs)); } ); @@ -849,8 +849,8 @@ void TestTuple() { always_check(A == 15); always_check(B == 514); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); + always_check((CSameAs)); + always_check((CSameAs)); } ); @@ -860,9 +860,9 @@ void TestTuple() always_check(A == '-'); always_check(B == 15); always_check(C == 514); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); + always_check((CSameAs)); + always_check((CSameAs)); + always_check((CSameAs)); }, '-' ); @@ -873,9 +873,9 @@ void TestTuple() always_check(A == '-'); always_check(B == 15); always_check(C == 514); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); + always_check((CSameAs)); + always_check((CSameAs)); + always_check((CSameAs)); }, '-' ); @@ -886,9 +886,9 @@ void TestTuple() always_check(A == 15); always_check(B == 514); always_check(C == '-'); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); + always_check((CSameAs)); + always_check((CSameAs)); + always_check((CSameAs)); }, '-' ); @@ -899,9 +899,9 @@ void TestTuple() always_check(A == 15); always_check(B == 514); always_check(C == '-'); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); - always_check((TIsSame::Value)); + always_check((CSameAs)); + always_check((CSameAs)); + always_check((CSameAs)); }, '-' ); @@ -914,8 +914,8 @@ void TestTuple() VisitTuple( [] (T&& A) { - if constexpr (TIsSame::Value) always_check(A == 2); - else if constexpr (TIsSame::Value) always_check(A == 'B'); + if constexpr (CSameAs) always_check(A == 2); + else if constexpr (CSameAs) always_check(A == 'B'); else always_check_no_entry(); }, TempB @@ -926,8 +926,8 @@ void TestTuple() VisitTuple( [] (T&& A) { - if constexpr (TIsSame::Value) always_check(A == 3); - else if constexpr (TIsSame::Value) always_check(A == 'C'); + if constexpr (CSameAs) always_check(A == 3); + else if constexpr (CSameAs) always_check(A == 'C'); else always_check_no_entry(); }, TempB @@ -953,7 +953,7 @@ void TestTuple() always_check(A == 1); always_check(B == 2.3); always_check(C == 'A'); - always_check((TIsSame::Value)); + always_check((CSameAs)); } always_check(GetTypeHash(MakeTuple(114, 1.0f)) == GetTypeHash(MakeTuple(114, 1.0f))); diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 47c8d6c..ff3f8a4 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -301,105 +301,94 @@ void TestTypeTraits() // Miscellaneous.h - always_check(TRank::Value == 3); - always_check(TRank::Value == 4); - always_check(TRank::Value == 0); + always_check(ArrayRank == 3); + always_check(ArrayRank == 4); + always_check(ArrayRank == 0); - always_check(TExtent::Value == 1); - always_check((TExtent::Value == 2)); - always_check(TExtent::Value == 0); + always_check(ArrayExtent == 1); + always_check((ArrayExtent == 2)); + always_check(ArrayExtent == 0); - always_check(!(TIsSame::Value)); - always_check((TIsSame::Value)); + always_check(!(CSameAs)); + always_check((CSameAs)); - always_check(!(TIsBaseOf::Value)); - always_check(!(TIsBaseOf::Value)); - always_check((TIsBaseOf::Value)); + always_check(!(CBaseOf)); + always_check(!(CBaseOf)); + always_check((CBaseOf)); - always_check((TIsConvertible::Value)); - always_check(!(TIsConvertible::Value)); - always_check((TIsConvertible::Value)); - always_check(!(TIsConvertible::Value)); - always_check((TIsConvertible::Value)); + always_check((CConvertibleTo)); + always_check(!(CConvertibleTo)); + always_check((CConvertibleTo)); + always_check(!(CConvertibleTo)); + always_check((CConvertibleTo)); - always_check((TIsInvocable::Value)); - always_check((TIsInvocable::Value)); - always_check(!(TIsInvocable::Value)); - always_check((TIsInvocable::Value)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); - always_check((TIsInvocableResult::Value)); - always_check((TIsInvocableResult::Value)); - always_check((TIsInvocableResult::Value)); - always_check(!(TIsInvocableResult::Value)); - always_check(!(TIsInvocableResult::Value)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check(!(CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check(!(CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check(!(TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); TAlignedStorage<32, 4>::Type Aligned4; TAlignedStorage<32, 8>::Type Aligned8; @@ -415,40 +404,60 @@ void TestTypeTraits() always_check(sizeof(TAlignedUnion<0, int32, int64>::Type) == 8); always_check(sizeof(TAlignedUnion<0, int32, double>::Type) == 8); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); -// always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + + // Invocable.h + + always_check((CInvocable)); + always_check((CInvocable)); + always_check(!(CInvocable)); + always_check((CInvocable)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CInvocableResult)); + always_check((CInvocableResult)); + always_check((CInvocableResult)); + always_check(!(CInvocableResult)); + always_check(!(CInvocableResult)); + + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); +// always_check((CSameAs::Type>)); + + always_check((CInvocable void { }) >)); + always_check((CRegularInvocable int32 { return A; }), int32 >)); + always_check((CPredicate bool { return (A + B + C) == 0; }), int32, int32, int32 >)); + always_check((CRelation bool { return (A ^ B) == 0; }), int32, int32 >)); + always_check((CEquivalenceRelation bool { return A == B; }), int32, int32 >)); + always_check((CStrictWeakOrder bool { return A < B; }), int32, int32 >)); // Common.h - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); // Swappable.h @@ -461,81 +470,88 @@ void TestTypeTraits() // CopyQualifiers.h - always_check((TIsSame< int32, TCopyConst< int32, int32>::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs< int32, TCopyConst< int32, int32>::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame< int32, TCopyVolatile< int32, int32>::Type>::Value)); - always_check((TIsSame< int32, TCopyVolatile::Type>::Value)); - always_check((TIsSame< volatile int32, TCopyVolatile::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs< int32, TCopyVolatile< int32, int32>::Type>)); + always_check((CSameAs< int32, TCopyVolatile::Type>)); + always_check((CSameAs< volatile int32, TCopyVolatile::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame< int32, TCopyCV< int32, int32>::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs< int32, TCopyCV< int32, int32>::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame< int32, TCopyCVRef< int32, int32>::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame< volatile int32, TCopyCVRef< volatile int32, int32>::Type>::Value)); - always_check((TIsSame< volatile int32, TCopyCVRef< int32, volatile int32>::Type>::Value)); - always_check((TIsSame< volatile int32, TCopyCVRef< volatile int32, volatile int32>::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs< int32, TCopyCVRef< int32, int32>::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs< volatile int32, TCopyCVRef< volatile int32, int32>::Type>)); + always_check((CSameAs< volatile int32, TCopyCVRef< int32, volatile int32>::Type>)); + always_check((CSameAs< volatile int32, TCopyCVRef< volatile int32, volatile int32>::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); - always_check((TIsSame::Type>::Value)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + always_check((CSameAs::Type>)); + + // BooleanTestable.h + + always_check(CBooleanTestable); + always_check(CBooleanTestable); + always_check(CBooleanTestable); + always_check(!CBooleanTestable); } diff --git a/Redcraft.Utility/Source/Public/Concepts/BooleanTestable.h b/Redcraft.Utility/Source/Public/Concepts/BooleanTestable.h index 69073b4..dbc924c 100644 --- a/Redcraft.Utility/Source/Public/Concepts/BooleanTestable.h +++ b/Redcraft.Utility/Source/Public/Concepts/BooleanTestable.h @@ -1,18 +1,12 @@ #pragma once #include "CoreTypes.h" -#include "Templates/Utility.h" -#include "Concepts/Convertible.h" #include "TypeTraits/TypeTraits.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template -concept CBooleanTestable = CConvertibleTo && - requires(T && B) { { !Forward(B) } -> CConvertibleTo; }; - NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Concepts/Convertible.h b/Redcraft.Utility/Source/Public/Concepts/Convertible.h index dc2f2a3..dbc924c 100644 --- a/Redcraft.Utility/Source/Public/Concepts/Convertible.h +++ b/Redcraft.Utility/Source/Public/Concepts/Convertible.h @@ -7,9 +7,6 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template -concept CConvertibleTo = TIsConvertible::Value && requires(T(&Func)()) { static_cast(Func()); }; - NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Concepts/Derived.h b/Redcraft.Utility/Source/Public/Concepts/Derived.h index 763696a..7d81d02 100644 --- a/Redcraft.Utility/Source/Public/Concepts/Derived.h +++ b/Redcraft.Utility/Source/Public/Concepts/Derived.h @@ -2,14 +2,13 @@ #include "CoreTypes.h" #include "TypeTraits/TypeTraits.h" -#include "Concepts/Convertible.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template -concept CDerivedFrom = TIsBaseOf::Value && CConvertibleTo; +concept CDerivedFrom = CBaseOf && CConvertibleTo; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/Concepts/Invocable.h b/Redcraft.Utility/Source/Public/Concepts/Invocable.h index 8300ff1..dbc924c 100644 --- a/Redcraft.Utility/Source/Public/Concepts/Invocable.h +++ b/Redcraft.Utility/Source/Public/Concepts/Invocable.h @@ -7,26 +7,6 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template -concept CInvocable = requires(F&& Func, Types&&... Args) { Invoke(Forward(Func), Forward(Args)...); }; - -template -concept CRegularInvocable = CInvocable; - -template -concept CPredicate = CRegularInvocable && CBooleanTestable::Type>; - -template -concept CRelation = - CPredicate && CPredicate && - CPredicate && CPredicate; - -template -concept CEquivalenceRelation = CRelation; - -template -concept CStrictWeakOrder = CRelation; - NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Concepts/Same.h b/Redcraft.Utility/Source/Public/Concepts/Same.h index 1a1ee61..dbc924c 100644 --- a/Redcraft.Utility/Source/Public/Concepts/Same.h +++ b/Redcraft.Utility/Source/Public/Concepts/Same.h @@ -7,9 +7,6 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template -concept CSameAs = TIsSame::Value && TIsSame::Value; - NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index a8bcaaa..98c0699 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -31,9 +31,9 @@ template struct TCommonComparisonCategory : NAMESPACE_PRIVATE::TCommonComparisonCategory<(0u | ... | ( - TIsSame::Value ? 0u : - TIsSame::Value ? 4u : - TIsSame::Value ? 2u : 1u + CSameAs ? 0u : + CSameAs ? 4u : + CSameAs ? 2u : 1u ) )> { }; diff --git a/Redcraft.Utility/Source/Public/Templates/Any.h b/Redcraft.Utility/Source/Public/Templates/Any.h index 2b57d67..175c018 100644 --- a/Redcraft.Utility/Source/Public/Templates/Any.h +++ b/Redcraft.Utility/Source/Public/Templates/Any.h @@ -76,7 +76,7 @@ struct alignas(InlineAlignment) TAny EmplaceImpl(Forward(Args)...); } - template requires (!TIsSame::Type, TAny>::Value) && (!TIsTInPlaceType::Type>::Value) + template requires (!CSameAs::Type, TAny>) && (!TIsTInPlaceType::Type>::Value) && CDestructible::Type> && CConstructible::Type, T&&> FORCEINLINE TAny(T&& InValue) : TAny(InPlaceType::Type>, Forward(InValue)) { } @@ -184,7 +184,7 @@ struct alignas(InlineAlignment) TAny return *this; } - template requires (!TIsSame::Type, TAny>::Value) && (!TIsTInPlaceType::Type>::Value) + template requires (!CSameAs::Type, TAny>) && (!TIsTInPlaceType::Type>::Value) && CDestructible::Type> && CConstructible::Type, T&&> FORCEINLINE TAny& operator=(T&& InValue) { @@ -233,10 +233,10 @@ struct alignas(InlineAlignment) TAny template requires CDestructible::Type> constexpr const T&& GetValue() const&& { checkf(HoldsAlternative(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(GetAllocation())); } - template requires TIsSame::Type>::Value&& CDestructible::Type> + template requires CSameAs::Type>&& CDestructible::Type> constexpr T& Get( T& DefaultValue) & { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires TIsSame::Type>::Value&& CDestructible::Type> + template requires CSameAs::Type>&& CDestructible::Type> constexpr const T& Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } FORCEINLINE void Reset() diff --git a/Redcraft.Utility/Source/Public/Templates/Atomic.h b/Redcraft.Utility/Source/Public/Templates/Atomic.h index cf0c4a7..a14e67c 100644 --- a/Redcraft.Utility/Source/Public/Templates/Atomic.h +++ b/Redcraft.Utility/Source/Public/Templates/Atomic.h @@ -121,7 +121,7 @@ public: FORCEINLINE void Notify(bool bIsAll = false) { if (bIsAll) Element.notify_all(); else Element.notify_one(); } FORCEINLINE void Notify(bool bIsAll = false) volatile { if (bIsAll) Element.notify_all(); else Element.notify_one(); } - template requires TIsInvocableResult::Value + template requires CInvocableResult FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) { ValueType Temp(Load(EMemoryOrder::Relaxed)); @@ -129,7 +129,7 @@ public: return Temp; } - template requires TIsInvocableResult::Value && bIsAlwaysLockFree + template requires CInvocableResult && bIsAlwaysLockFree FORCEINLINE ValueType FetchFn(F&& Func, EMemoryOrder Order = EMemoryOrder::SequentiallyConsistent) volatile { ValueType Temp(Load(EMemoryOrder::Relaxed)); diff --git a/Redcraft.Utility/Source/Public/Templates/Function.h b/Redcraft.Utility/Source/Public/Templates/Function.h index 717e60d..012c46d 100644 --- a/Redcraft.Utility/Source/Public/Templates/Function.h +++ b/Redcraft.Utility/Source/Public/Templates/Function.h @@ -56,19 +56,19 @@ template struct TIsInvocableSignature : FFalse template struct TIsInvocableSignature - : TBoolConstant::Value && TIsInvocableResult::Value> + : TBoolConstant && CInvocableResult> { }; -template struct TIsInvocableSignature : TIsInvocableResult { }; -template struct TIsInvocableSignature : TIsInvocableResult { }; +template struct TIsInvocableSignature : TBoolConstant> { }; +template struct TIsInvocableSignature : TBoolConstant> { }; template struct TIsInvocableSignature - : TBoolConstant::Value && TIsInvocableResult::Value> + : TBoolConstant && CInvocableResult> { }; -template struct TIsInvocableSignature : TIsInvocableResult { }; -template struct TIsInvocableSignature : TIsInvocableResult { }; +template struct TIsInvocableSignature : TBoolConstant> { }; +template struct TIsInvocableSignature : TBoolConstant> { }; template struct TFunctionInfo; template struct TFunctionInfo { using Fn = Ret(Types...); using CVRef = int; }; @@ -95,12 +95,12 @@ public: TFunctionImpl& operator=(TFunctionImpl&&) = default; ~TFunctionImpl() = default; - FORCEINLINE ResultType operator()(Types... Args) requires (TIsSame::Value) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) & requires (TIsSame::Value) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) && requires (TIsSame::Value) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) const requires (TIsSame::Value) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) const& requires (TIsSame::Value) { return CallImpl(Forward(Args)...); } - FORCEINLINE ResultType operator()(Types... Args) const&& requires (TIsSame::Value) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Types... Args) requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Types... Args) & requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Types... Args) && requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Types... Args) const requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Types... Args) const& requires (CSameAs) { return CallImpl(Forward(Args)...); } + FORCEINLINE ResultType operator()(Types... Args) const&& requires (CSameAs) { return CallImpl(Forward(Args)...); } constexpr bool IsValid() const { return Callable != nullptr; } constexpr explicit operator bool() const { return Callable != nullptr; } @@ -478,28 +478,28 @@ struct TNotFunction template constexpr TNotFunction(InF&& InFunc) : Storage(Forward(InFunc)) { } - template requires TIsInvocable::Value + template requires CInvocable constexpr auto operator()(Types&&... Args) & -> decltype(!Invoke(Storage, Forward(Args)...)) { return !Invoke(Storage, Forward(Args)...); } - template requires TIsInvocable::Value + template requires CInvocable constexpr auto operator()(Types&&... Args) && -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { return !Invoke(MoveTemp(Storage), Forward(Args)...); } - template requires TIsInvocable::Value + template requires CInvocable constexpr auto operator()(Types&&... Args) const& -> decltype(!Invoke(Storage, Forward(Args)...)) { return !Invoke(Storage, Forward(Args)...); } - template requires TIsInvocable::Value + template requires CInvocable constexpr auto operator()(Types&&... Args) const&& -> decltype(!Invoke(MoveTemp(Storage), Forward(Args)...)) { diff --git a/Redcraft.Utility/Source/Public/Templates/Invoke.h b/Redcraft.Utility/Source/Public/Templates/Invoke.h index 2e9dcdc..c3cf9ce 100644 --- a/Redcraft.Utility/Source/Public/Templates/Invoke.h +++ b/Redcraft.Utility/Source/Public/Templates/Invoke.h @@ -81,14 +81,14 @@ struct InvokeImpl : InvokeMember { }; NAMESPACE_PRIVATE_END -template requires TIsInvocable::Value +template requires CInvocable constexpr auto Invoke(F&& Func, Types&&... Args) -> decltype(NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...)) { return NAMESPACE_PRIVATE::InvokeImpl::Invoke(Forward(Func), Forward(Args)...); } -template requires TIsInvocableResult::Value +template requires CInvocableResult constexpr R InvokeResult(F&& Func, Types&&... Args) { if constexpr (CVoid) Invoke(Forward(Func), Forward(Args)...); diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index 02979f1..05105cb 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -23,10 +23,10 @@ private: || CConstructible& > || CConstructible&&> || CConstructible&&> - || TIsConvertible< TOptional&, OptionalType>::Value - || TIsConvertible&, OptionalType>::Value - || TIsConvertible< TOptional&&, OptionalType>::Value - || TIsConvertible&&, OptionalType>::Value + || CConvertibleTo< TOptional&, OptionalType> + || CConvertibleTo&, OptionalType> + || CConvertibleTo< TOptional&&, OptionalType> + || CConvertibleTo&&, OptionalType> || CAssignable& > || CAssignable& > || CAssignable&&> @@ -49,8 +49,8 @@ public: } template requires CConstructible - && (!TIsSame::Type, FInPlace>::Value) && (!TIsSame::Type, TOptional>::Value) - constexpr explicit (!TIsConvertible::Value) TOptional(T&& InValue) + && (!CSameAs::Type, FInPlace>) && (!CSameAs::Type, TOptional>) + constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } @@ -67,14 +67,14 @@ public: } template requires CConstructible && TAllowUnwrapping::Value - constexpr explicit (!TIsConvertible::Value) TOptional(const TOptional& InValue) + constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue()); } template requires CConstructible && TAllowUnwrapping::Value - constexpr explicit (!TIsConvertible::Value) TOptional(TOptional&& InValue) + constexpr explicit (!CConvertibleTo) TOptional(TOptional&& InValue) : bIsValid(InValue.IsValid()) { if (InValue.IsValid()) new(&Value) OptionalType(MoveTemp(InValue.GetValue())); diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index eb27c21..3f415f6 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -17,19 +17,19 @@ public: using Type = ReferencedType; - template requires TIsConvertible::Value + template requires CConvertibleTo constexpr TReferenceWrapper(T&& Object) : Pointer(AddressOf(Forward(Object))) { } TReferenceWrapper(const TReferenceWrapper&) = default; - template requires TIsConvertible::Value + template requires CConvertibleTo constexpr TReferenceWrapper(const TReferenceWrapper& InValue) : Pointer(InValue.Pointer) { } TReferenceWrapper& operator=(const TReferenceWrapper&) = default; - template requires TIsConvertible::Value + template requires CConvertibleTo constexpr TReferenceWrapper& operator=(const TReferenceWrapper& InValue) { Pointer = InValue.Pointer; @@ -120,10 +120,10 @@ private: || CConstructible& > || CConstructible&&> || CConstructible&&> - || TIsConvertible< TOptional&, OptionalType>::Value - || TIsConvertible&, OptionalType>::Value - || TIsConvertible< TOptional&&, OptionalType>::Value - || TIsConvertible&&, OptionalType>::Value + || CConvertibleTo< TOptional&, OptionalType> + || CConvertibleTo&, OptionalType> + || CConvertibleTo< TOptional&&, OptionalType> + || CConvertibleTo&&, OptionalType> || CAssignable& > || CAssignable& > || CAssignable&&> @@ -144,8 +144,8 @@ public: { } template requires CConstructible - && (!TIsSame::Type, FInPlace>::Value) && (!TIsSame::Type, TOptional>::Value) - constexpr explicit (!TIsConvertible::Value) TOptional(T&& InValue) + && (!CSameAs::Type, FInPlace>) && (!CSameAs::Type, TOptional>) + constexpr explicit (!CConvertibleTo) TOptional(T&& InValue) : TOptional(InPlace, Forward(InValue)) { } @@ -153,7 +153,7 @@ public: TOptional(TOptional&& InValue) = default; template requires CConstructible && TAllowUnwrapping::Value - constexpr explicit (!TIsConvertible::Value) TOptional(const TOptional& InValue) + constexpr explicit (!CConvertibleTo) TOptional(const TOptional& InValue) : Reference(InValue.Reference) { } diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 7107790..e4b9455 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -32,7 +32,7 @@ struct TTupleElementIndex; template struct TTupleElementIndex - : TConstant::Value ? 0 : (TTupleElementIndex::Value == INDEX_NONE + : TConstant ? 0 : (TTupleElementIndex::Value == INDEX_NONE ? INDEX_NONE : TTupleElementIndex::Value + 1)> { }; @@ -237,54 +237,54 @@ public: template requires (ElementSize > 0) && (sizeof...(ArgTypes) == ElementSize) && (true && ... && CConstructible) - && (true && ... && TIsConvertible::Value) + && (true && ... && CConvertibleTo) constexpr TTuple(ArgTypes&&... Args) : Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward(Args)...) { } template requires (ElementSize > 0) && (sizeof...(ArgTypes) == ElementSize) && (true && ... && CConstructible) - && (!(true && ... && TIsConvertible::Value)) + && (!(true && ... && CConvertibleTo)) constexpr explicit TTuple(ArgTypes&&... Args) : Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward(Args)...) { } template requires (sizeof...(OtherTypes) == ElementSize) && (true && ... && CConstructible) - && ((ElementSize != 1) || !(TIsConvertible&, typename TElementType<0>::Type>::Value + && ((ElementSize != 1) || !(CConvertibleTo&, typename TElementType<0>::Type> || CConstructible::Type, const TTuple&> - || TIsSame::Type, typename TTuple::template TElementType<0>::Type>::Value)) - && (true && ... && TIsConvertible::Value) + || CSameAs::Type, typename TTuple::template TElementType<0>::Type>)) + && (true && ... && CConvertibleTo) constexpr TTuple(const TTuple& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) { } template requires (sizeof...(OtherTypes) == ElementSize) && (true && ... && CConstructible) - && ((ElementSize != 1) || !(TIsConvertible&, typename TElementType<0>::Type>::Value + && ((ElementSize != 1) || !(CConvertibleTo&, typename TElementType<0>::Type> || CConstructible::Type, const TTuple&> - || TIsSame::Type, typename TTuple::template TElementType<0>::Type>::Value)) - && (!(true && ... && TIsConvertible::Value)) + || CSameAs::Type, typename TTuple::template TElementType<0>::Type>)) + && (!(true && ... && CConvertibleTo)) constexpr explicit TTuple(const TTuple& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue) { } template requires (sizeof...(OtherTypes) == ElementSize) && (true && ... && CConstructible) - && ((ElementSize != 1) || !(TIsConvertible&&, typename TElementType<0>::Type>::Value + && ((ElementSize != 1) || !(CConvertibleTo&&, typename TElementType<0>::Type> || CConstructible::Type, TTuple&&> - || TIsSame::Type, typename TTuple::template TElementType<0>::Type>::Value)) - && (true && ... && TIsConvertible::Value) + || CSameAs::Type, typename TTuple::template TElementType<0>::Type>)) + && (true && ... && CConvertibleTo) constexpr TTuple(TTuple&& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) { } template requires (sizeof...(OtherTypes) == ElementSize) && (true && ... && CConstructible) - && ((ElementSize != 1) || !(TIsConvertible&&, typename TElementType<0>::Type>::Value + && ((ElementSize != 1) || !(CConvertibleTo&&, typename TElementType<0>::Type> || CConstructible::Type, TTuple&&> - || TIsSame::Type, typename TTuple::template TElementType<0>::Type>::Value)) - && (!(true && ... && TIsConvertible::Value)) + || CSameAs::Type, typename TTuple::template TElementType<0>::Type>)) + && (!(true && ... && CConvertibleTo)) constexpr explicit TTuple(TTuple&& InValue) : Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue)) { } @@ -329,41 +329,41 @@ public: template requires (TElementIndex::Value != INDEX_NONE) constexpr volatile T&& GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue::Value>(); } template requires (TElementIndex::Value != INDEX_NONE) constexpr const volatile T&& GetValue() const volatile&& { return static_cast(*this).GetValue::Value>(); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) & { return Helper::Apply(Forward(Func), static_cast< TTuple& >(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) const & { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) volatile& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple& >(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) const volatile& { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) && { return Helper::Apply(Forward(Func), static_cast< TTuple&&>(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) const && { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) volatile&& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } - template requires TIsInvocable::Value constexpr auto Apply(F&& Func) const volatile&& { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) & { return Helper::Apply(Forward(Func), static_cast< TTuple& >(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) const & { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) volatile& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) const volatile& { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) && { return Helper::Apply(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) const && { return Helper::Apply(Forward(Func), static_cast(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) volatile&& { return Helper::Apply(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires CInvocable constexpr auto Apply(F&& Func) const volatile&& { return Helper::Apply(Forward(Func), static_cast(*this)); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } - template requires TIsInvocable::Value constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple& >(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward(Func), static_cast< TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast< volatile TTuple&&>(*this), Forward(Args)...); } + template requires CInvocable constexpr auto ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward(Func), static_cast(*this), Forward(Args)...); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } - template requires (true && ... && (TIsInvocable::Value && !TIsSame::Type>::Value)) constexpr auto Transform(F&& Func) const volatile&& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) & { return Helper::Transform(Forward(Func), static_cast< TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) const & { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) volatile& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple& >(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) const volatile& { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) && { return Helper::Transform(Forward(Func), static_cast< TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) const && { return Helper::Transform(Forward(Func), static_cast(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) volatile&& { return Helper::Transform(Forward(Func), static_cast< volatile TTuple&&>(*this)); } + template requires (true && ... && (CInvocable && !CSameAs::Type>)) constexpr auto Transform(F&& Func) const volatile&& { return Helper::Transform(Forward(Func), static_cast(*this)); } template requires CConstructible constexpr T Construct() & { return Helper::template Construct(static_cast< TTuple& >(*this)); } template requires CConstructible constexpr T Construct() const & { return Helper::template Construct(static_cast(*this)); } @@ -565,7 +565,7 @@ constexpr typename TCommonComparisonCategory>::F(LHS, RHS); } -template requires TIsInvocable::Value +template requires CInvocable constexpr void VisitTuple(F&& Func) { } template diff --git a/Redcraft.Utility/Source/Public/Templates/TypeHash.h b/Redcraft.Utility/Source/Public/Templates/TypeHash.h index 7b8f26a..9805a14 100644 --- a/Redcraft.Utility/Source/Public/Templates/TypeHash.h +++ b/Redcraft.Utility/Source/Public/Templates/TypeHash.h @@ -40,7 +40,7 @@ constexpr size_t HashCombine(size_t A, size_t C) return C; } -template requires (true && ... && TIsConvertible::Value) +template requires (true && ... && CConvertibleTo) constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther) { size_t B = HashCombine(A, C); @@ -81,7 +81,7 @@ constexpr size_t GetTypeHash(T A) return GetTypeHash(static_cast::Type>(A)); } -template requires CPointer || TIsSame::Value +template requires CPointer || CSameAs constexpr size_t GetTypeHash(T A) { return GetTypeHash(reinterpret_cast(A)); diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index fc849df..ea11144 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -20,7 +20,7 @@ struct TVariantAlternativeIndex; template struct TVariantAlternativeIndex - : TConstant::Value ? 0 : (TVariantAlternativeIndex::Value == INDEX_NONE + : TConstant ? 0 : (TVariantAlternativeIndex::Value == INDEX_NONE ? INDEX_NONE : TVariantAlternativeIndex::Value + 1)> { }; @@ -52,18 +52,18 @@ struct TVariantSelectedType using TypeAlternativeA = typename TConditional, U, void>::Type; using TypeAlternativeB = typename TVariantSelectedType::Type; - using Type = typename TConditional::Type, void>::Value, TypeAlternativeB, - typename TConditional::Type, void>::Value, TypeAlternativeA, - typename TConditional::Type, typename TRemoveCVRef::Type>::Value, TypeAlternativeB, TypeAlternativeA>::Type>::Type>::Type; + using Type = typename TConditional::Type, void>, TypeAlternativeB, + typename TConditional::Type, void>, TypeAlternativeA, + typename TConditional::Type, typename TRemoveCVRef::Type>, TypeAlternativeB, TypeAlternativeA>::Type>::Type>::Type; // 0 - Type not found // 1 - Same type found // 2 - Multiple types found // 3 - The type found - static constexpr uint8 Flag = TIsSame::Type, void>::Value ? 0 : - TIsSame::Type, typename TRemoveCVRef::Type>::Value ? 2 : - TIsSame::Type, typename TRemoveCVRef< T>::Type>::Value ? 1 : - !TIsSame::Type, void>::Value && !TIsSame::Value ? 2 : 3; + static constexpr uint8 Flag = CSameAs::Type, void> ? 0 : + CSameAs::Type, typename TRemoveCVRef::Type> ? 2 : + CSameAs::Type, typename TRemoveCVRef< T>::Type> ? 1 : + !CSameAs::Type, void> && !CSameAs ? 2 : 3; static constexpr bool Value = Flag & 1; @@ -119,7 +119,7 @@ struct TVariant template requires NAMESPACE_PRIVATE::TVariantSelectedType::Type, Types...>::Value && (!TIsTInPlaceType::Type>::Value) && (!TIsTInPlaceIndex::Type>::Value) - && (!TIsSame::Type, TVariant>::Value) + && (!CSameAs::Type, TVariant>) constexpr TVariant(T&& InValue) : TVariant(InPlaceType::Type, Types...>::Type>, Forward(InValue)) { } @@ -231,7 +231,7 @@ struct TVariant template requires (TAlternativeIndex::Value != INDEX_NONE) constexpr T& Get(T& DefaultValue)& { return HoldsAlternative() ? GetValue() : DefaultValue; } template requires (TAlternativeIndex::Value != INDEX_NONE) constexpr const T& Get(const T& DefaultValue) const& { return HoldsAlternative() ? GetValue() : DefaultValue; } - template requires (true && ... && TIsInvocable::Value) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) & { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); @@ -244,7 +244,7 @@ struct TVariant return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && TIsInvocable::Value) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) && { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); @@ -257,7 +257,7 @@ struct TVariant return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && TIsInvocable::Value) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) const& { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); @@ -270,7 +270,7 @@ struct TVariant return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && TIsInvocable::Value) + template requires (true && ... && CInvocable) FORCEINLINE decltype(auto) Visit(F&& Func) const&& { checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid().")); @@ -283,16 +283,16 @@ struct TVariant return InvokeImpl[GetIndex()](Forward(Func), &Value); } - template requires (true && ... && TIsInvocableResult::Value) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) & { return Visit(Forward(Func)); } - template requires (true && ... && TIsInvocableResult::Value) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) && { return MoveTemp(*this).Visit(Forward(Func)); } - template requires (true && ... && TIsInvocableResult::Value) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) const& { return Visit(Forward(Func)); } - template requires (true && ... && TIsInvocableResult::Value) + template requires (true && ... && CInvocableResult) FORCEINLINE R Visit(F&& Func) const&& { return MoveTemp(*this).Visit(Forward(Func)); } constexpr void Reset() @@ -397,7 +397,7 @@ private: }; -template requires (!TIsSame>::Value) && CEqualityComparable +template requires (!CSameAs>) && CEqualityComparable constexpr bool operator==(const TVariant& LHS, const T& RHS) { return LHS.template HoldsAlternative() ? LHS.template GetValue() == RHS : false; diff --git a/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h b/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h index f35958a..86c9d22 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h @@ -35,9 +35,9 @@ template struct TIsBitwiseConstructible struct TIsBitwiseConstructible : TIsBitwiseConstructible { }; template struct TIsBitwiseConstructible : TIsBitwiseConstructible { }; -template struct TIsBitwiseConstructible : TIsConvertible { }; +template struct TIsBitwiseConstructible : TBoolConstant> { }; -template struct TIsBitwiseConstructible : TBoolConstant::Value ? CTriviallyCopyConstructible : false> { }; +template struct TIsBitwiseConstructible : TBoolConstant ? CTriviallyCopyConstructible : false> { }; template <> struct TIsBitwiseConstructible : FTrue { }; template <> struct TIsBitwiseConstructible< int8, uint8> : FTrue { }; diff --git a/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h b/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h new file mode 100644 index 0000000..ab1f406 --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h @@ -0,0 +1,17 @@ +#pragma once + +#include "CoreTypes.h" +#include "Templates/Utility.h" +#include "TypeTraits/Miscellaneous.h" + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) + +template +concept CBooleanTestable = CConvertibleTo && + requires(T && B) { { !Forward(B) } -> CConvertibleTo; }; + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h b/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h new file mode 100644 index 0000000..dadf4ee --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/Invocable.h @@ -0,0 +1,36 @@ +#pragma once + +#include "CoreTypes.h" +#include "TypeTraits/BooleanTestable.h" + +#include + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) + +template concept CInvocable = NAMESPACE_STD::is_invocable_v; +template concept CInvocableResult = NAMESPACE_STD::is_invocable_r_v; // FIXME: The result for char(&())[2] is wrong on MSVC + +template struct TInvokeResult { using Type = NAMESPACE_STD::invoke_result_t; }; // FIXME: The result for char(&())[2] is wrong on MSVC + +template +concept CRegularInvocable = CInvocable; + +template +concept CPredicate = CRegularInvocable && CBooleanTestable::Type>; + +template +concept CRelation = + CPredicate && CPredicate && + CPredicate && CPredicate; + +template +concept CEquivalenceRelation = CRelation; + +template +concept CStrictWeakOrder = CRelation; + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h index f99f78f..987c7ad 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h @@ -25,14 +25,12 @@ struct TMaximum : TMaximum<(First < Second ? Second : NAMESPACE_PRIVATE_END -template struct TRank : TConstant> { }; -template struct TExtent : TConstant> { }; +template inline constexpr size_t ArrayRank = NAMESPACE_STD::rank_v; +template inline constexpr size_t ArrayExtent = NAMESPACE_STD::extent_v; -template struct TIsSame : TBoolConstant> { }; -template struct TIsBaseOf : TBoolConstant> { }; -template struct TIsConvertible : TBoolConstant> { }; -template struct TIsInvocable : TBoolConstant> { }; -template struct TIsInvocableResult : TBoolConstant> { }; // FIXME: The result for char(&())[2] is wrong on MSVC +template concept CSameAs = NAMESPACE_STD::is_same_v; +template concept CBaseOf = NAMESPACE_STD::is_base_of_v; +template concept CConvertibleTo = NAMESPACE_STD::is_convertible_v; template struct TRemoveConst { using Type = NAMESPACE_STD::remove_const_t; }; template struct TRemoveVolatile { using Type = NAMESPACE_STD::remove_volatile_t; }; @@ -52,7 +50,6 @@ template struct TDecay { using Type = template struct TEnableIf { using Type = NAMESPACE_STD::enable_if_t; }; template struct TConditional { using Type = NAMESPACE_STD::conditional_t; }; template struct TUnderlyingType { using Type = NAMESPACE_STD::underlying_type_t; }; -template struct TInvokeResult { using Type = NAMESPACE_STD::invoke_result_t; }; // FIXME: The result for char(&())[2] is wrong on MSVC template struct TVoid { using Type = void; }; NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h b/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h index 0d861f0..19c01e9 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h @@ -1,7 +1,6 @@ #pragma once #include "CoreTypes.h" -#include "TypeTraits/HelperClasses.h" #include diff --git a/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h b/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h index baa71b9..b7a46c9 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h @@ -25,7 +25,7 @@ template concept CSigned = NAMESPACE_STD::is_sig template concept CUnsigned = NAMESPACE_STD::is_unsigned_v; template concept CBoundedArray = NAMESPACE_STD::is_bounded_array_v; template concept CUnboundedArray = NAMESPACE_STD::is_unbounded_array_v; -template concept CScopedEnum = CEnum && !TIsConvertible::Value; +template concept CScopedEnum = CEnum && !CConvertibleTo; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h index 1d8d0e9..70265e6 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h @@ -7,8 +7,10 @@ #include "TypeTraits/TypeProperties.h" #include "TypeTraits/SupportedOperations.h" #include "TypeTraits/Miscellaneous.h" +#include "TypeTraits/Invocable.h" #include "TypeTraits/Swappable.h" #include "TypeTraits/Common.h" #include "TypeTraits/CopyQualifiers.h" #include "TypeTraits/InPlaceSpecialization.h" #include "TypeTraits/BitwiseOperations.h" +#include "TypeTraits/BooleanTestable.h"