refactor(typetraits): simplifies concept selection and removes the concept of bitwise operations

This commit is contained in:
2022-05-21 22:39:22 +08:00
parent ee46d84897
commit 97910be70c
14 changed files with 93 additions and 263 deletions

View File

@ -152,7 +152,6 @@ struct FTracker
~FTracker() { always_check(Status == 3); Status = -1; }
FTracker& operator=(const FTracker&) { always_check(Status == 4); Status = -1; return *this; }
FTracker& operator=(FTracker&&) { always_check(Status == 5); Status = -1; return *this; }
friend bool operator==(const FTracker&, const FTracker&) { always_check(Status == 6); Status = -1; return true; }
};
int32 FTracker::Status = -1;
@ -181,10 +180,6 @@ void TestMemoryOperator()
Memory::MoveConstruct(PtrA, PtrB);
always_check(FTracker::Status == -1);
FTracker::Status = -1;
Memory::RelocateConstruct(PtrA, PtrB);
always_check(FTracker::Status == -1);
FTracker::Status = 3;
Memory::Destruct(PtrA);
always_check(FTracker::Status == -1);
@ -197,11 +192,6 @@ void TestMemoryOperator()
Memory::MoveAssign(PtrA, PtrB);
always_check(FTracker::Status == -1);
FTracker::Status = 6;
const bool bResult = Memory::Compare(PtrA, PtrB);
always_check(bResult);
always_check(FTracker::Status == -1);
Memory::Free(PtrA);
Memory::Free(PtrB);
}

View File

@ -110,8 +110,11 @@ struct FTestSynth
{
int32 A;
FTestSynth(int32 InA) : A(InA) { }
friend bool operator==(FTestSynth LHS, FTestSynth RHS) { return LHS.A == RHS.A; }
friend bool operator< (FTestSynth LHS, FTestSynth RHS) { return LHS.A < RHS.A; }
friend bool operator<=(FTestSynth LHS, FTestSynth RHS) { return LHS.A <= RHS.A; }
friend bool operator==(FTestSynth LHS, FTestSynth RHS) { return LHS.A == RHS.A; }
friend bool operator>=(FTestSynth LHS, FTestSynth RHS) { return LHS.A >= RHS.A; }
friend bool operator> (FTestSynth LHS, FTestSynth RHS) { return LHS.A > RHS.A; }
};
NAMESPACE_UNNAMED_END
@ -194,8 +197,8 @@ void TestCompare()
always_check(CThreeWayComparable<FTestWeakOrdering>);
always_check(CThreeWayComparable<FTestStrongOrdering>);
always_check((CThreeWayComparableWith<bool, bool>));
always_check((CThreeWayComparableWith<int16, int32>));
always_check((CThreeWayComparable<bool, bool>));
always_check((CThreeWayComparable<int16, int32>));
always_check((CSameAs<TCompareThreeWayResult<int32 >::Type, strong_ordering >));
always_check((CSameAs<TCompareThreeWayResult<float >::Type, partial_ordering>));

View File

@ -459,15 +459,15 @@ void TestTypeTraits()
always_check((CSameAs<int64, TCommonReference<int8, int32, int64>::Type>));
always_check((CSameAs<double, TCommonReference<float, double>::Type>));
always_check((CCommonWith<int32, int32>));
always_check((CCommonWith<int8, int32>));
always_check((CCommonWith<float, double>));
always_check(!(CCommonWith<FTestStructA, int32>));
always_check((CCommonType<int32, int32>));
always_check((CCommonType<int8, int32>));
always_check((CCommonType<float, double>));
always_check(!(CCommonType<FTestStructA, int32>));
always_check((CCommonReferenceWith<int8, int32>));
always_check((CCommonReferenceWith<float, int32>));
always_check((CCommonReferenceWith<float, double>));
always_check(!(CCommonReferenceWith<FTestStructA, double>));
always_check((CCommonReference<int8, int32>));
always_check((CCommonReference<float, int32>));
always_check((CCommonReference<float, double>));
always_check(!(CCommonReference<FTestStructA, double>));
// Swappable.h
@ -476,7 +476,7 @@ void TestTypeTraits()
always_check(CSwappable<FTestStructN>);
always_check(!CSwappable<FSingleton>);
always_check((CSwappableWith<int32&, int32&>));
always_check((CSwappable<int32&, int32&>));
// CopyQualifiers.h
@ -585,16 +585,16 @@ void TestTypeTraits()
always_check((CEqualityComparable<int32>));
always_check(!(CEqualityComparable<FTestStructA>));
always_check((CEqualityComparableWith<int32, int32>));
always_check((CEqualityComparableWith<int32, int64>));
always_check(!(CEqualityComparableWith<FTestStructA, FTestStructA>));
always_check((CEqualityComparable<int32, int32>));
always_check((CEqualityComparable<int32, int64>));
always_check(!(CEqualityComparable<FTestStructA, FTestStructA>));
always_check((CTotallyOrdered<int32>));
always_check(!(CTotallyOrdered<FTestStructA>));
always_check((CTotallyOrderedWith<int32, int32>));
always_check((CTotallyOrderedWith<int32, int64>));
always_check(!(CTotallyOrderedWith<FTestStructA, FTestStructA>));
always_check((CTotallyOrdered<int32, int32>));
always_check((CTotallyOrdered<int32, int64>));
always_check(!(CTotallyOrdered<FTestStructA, FTestStructA>));
}