From 97910be70c326c8519f0e9826c2c2c4d3ce94aa4 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Sat, 21 May 2022 22:39:22 +0800 Subject: [PATCH] refactor(typetraits): simplifies concept selection and removes the concept of bitwise operations --- .../Source/Private/Testing/MemoryTesting.cpp | 10 --- .../Private/Testing/MiscellaneousTesting.cpp | 9 ++- .../Private/Testing/TypeTraitsTesting.cpp | 30 ++++---- .../Source/Public/Memory/MemoryOperator.h | 67 +++--------------- .../Source/Public/Miscellaneous/Compare.h | 52 +++++--------- .../Source/Public/Templates/Optional.h | 6 +- .../Source/Public/Templates/Tuple.h | 4 +- .../Public/TypeTraits/BitwiseOperations.h | 68 ------------------- .../Public/TypeTraits/BooleanTestable.h | 4 +- .../Source/Public/TypeTraits/Common.h | 32 +++------ .../Source/Public/TypeTraits/Comparable.h | 38 ++++------- .../Source/Public/TypeTraits/Object.h | 15 ++-- .../Source/Public/TypeTraits/Swappable.h | 20 +++--- .../Source/Public/TypeTraits/TypeTraits.h | 1 - 14 files changed, 93 insertions(+), 263 deletions(-) delete mode 100644 Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h diff --git a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp index fc80494..a11cee6 100644 --- a/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/MemoryTesting.cpp @@ -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); } diff --git a/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp b/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp index 03b8df1..ab250fd 100644 --- a/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/MiscellaneousTesting.cpp @@ -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); always_check(CThreeWayComparable); - always_check((CThreeWayComparableWith)); - always_check((CThreeWayComparableWith)); + always_check((CThreeWayComparable)); + always_check((CThreeWayComparable)); always_check((CSameAs::Type, strong_ordering >)); always_check((CSameAs::Type, partial_ordering>)); diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 47bcead..00967d1 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -459,15 +459,15 @@ void TestTypeTraits() always_check((CSameAs::Type>)); always_check((CSameAs::Type>)); - always_check((CCommonWith)); - always_check((CCommonWith)); - always_check((CCommonWith)); - always_check(!(CCommonWith)); + always_check((CCommonType)); + always_check((CCommonType)); + always_check((CCommonType)); + always_check(!(CCommonType)); - always_check((CCommonReferenceWith)); - always_check((CCommonReferenceWith)); - always_check((CCommonReferenceWith)); - always_check(!(CCommonReferenceWith)); + always_check((CCommonReference)); + always_check((CCommonReference)); + always_check((CCommonReference)); + always_check(!(CCommonReference)); // Swappable.h @@ -476,7 +476,7 @@ void TestTypeTraits() always_check(CSwappable); always_check(!CSwappable); - always_check((CSwappableWith)); + always_check((CSwappable)); // CopyQualifiers.h @@ -585,16 +585,16 @@ void TestTypeTraits() always_check((CEqualityComparable)); always_check(!(CEqualityComparable)); - always_check((CEqualityComparableWith)); - always_check((CEqualityComparableWith)); - always_check(!(CEqualityComparableWith)); + always_check((CEqualityComparable)); + always_check((CEqualityComparable)); + always_check(!(CEqualityComparable)); always_check((CTotallyOrdered)); always_check(!(CTotallyOrdered)); - always_check((CTotallyOrderedWith)); - always_check((CTotallyOrderedWith)); - always_check(!(CTotallyOrderedWith)); + always_check((CTotallyOrdered)); + always_check((CTotallyOrdered)); + always_check(!(CTotallyOrdered)); } diff --git a/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h b/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h index 5dd5282..6c9b325 100644 --- a/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h +++ b/Redcraft.Utility/Source/Public/Memory/MemoryOperator.h @@ -15,13 +15,9 @@ template requires CDefaultConstructible FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1) { - if constexpr (CZeroConstructible) + if constexpr (!CTriviallyDefaultConstructible) { - Memory::Memset(Address, 0, sizeof(ElementType) * Count); - } - else - { - ElementType* Element = (ElementType*)Address; + ElementType* Element = Address; while (Count) { new (Element) ElementType; @@ -35,7 +31,7 @@ template FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElementType* Source, size_t Count = 1) { - if constexpr (CBitwiseConstructible) + if constexpr (CTriviallyConstructibleFrom && sizeof(DestinationElementType) == sizeof(SourceElementType)) { Memory::Memcpy(Destination, Source, sizeof(SourceElementType) * Count); } @@ -91,43 +87,6 @@ FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, si } } -template - requires CConstructibleFrom && CDestructible -FORCEINLINE void RelocateConstruct(DestinationElementType* Destination, SourceElementType* Source, size_t Count = 1) -{ - if constexpr (CBitwiseRelocatable) - { - Memory::Memmove(Destination, Source, sizeof(SourceElementType) * Count); - } - else - { - while (Count) - { - typedef SourceElementType RelocateConstructItemsElementTypeTypedef; - - new (Destination) DestinationElementType(MoveTemp(*Source)); - ++(DestinationElementType*&)Destination; - (Source++)->RelocateConstructItemsElementTypeTypedef::~RelocateConstructItemsElementTypeTypedef(); - --Count; - } - } -} - -template - requires CDestructible -FORCEINLINE void Destruct(ElementType* Element, size_t Count = 1) -{ - if constexpr (!CTriviallyDestructible) - { - while (Count) - { - Element->~ElementType(); - ++Element; - --Count; - } - } -} - template requires CCopyAssignable FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source, size_t Count = 1) @@ -152,7 +111,7 @@ template requires CMoveAssignable FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_t Count = 1) { - if constexpr (CTriviallyCopyConstructible) + if constexpr (CTriviallyMoveAssignable) { Memory::Memmove(Destination, Source, sizeof(ElementType) * Count); } @@ -169,25 +128,17 @@ FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_ } template - requires CEqualityComparable -FORCEINLINE bool Compare(const ElementType* LHS, const ElementType* RHS, size_t Count = 1) + requires CDestructible +FORCEINLINE void Destruct(ElementType* Element, size_t Count = 1) { - if constexpr (CBitwiseComparable) - { - return !Memory::Memcmp(LHS, RHS, sizeof(ElementType) * Count); - } - else + if constexpr (!CTriviallyDestructible) { while (Count) { - if (!(*LHS == *RHS)) return false; - - ++LHS; - ++RHS; + Element->~ElementType(); + ++Element; --Count; } - - return true; } } diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h index 59948af..3c119af 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Compare.h @@ -40,53 +40,35 @@ struct TCommonComparisonCategory template concept CThreeWayComparesAs = CSameAs::Type, OrderingType>; -template -concept CThreeWayComparable = CWeaklyEqualityComparableWith && CPartiallyOrderedWith && - requires(const TRemoveReference::Type& A, const TRemoveReference::Type& B) - { - { A <=> B } -> CThreeWayComparesAs; - }; - -template -concept CThreeWayComparableWith = CWeaklyEqualityComparableWith && CPartiallyOrderedWith && - CThreeWayComparable && CThreeWayComparable && - CCommonReferenceWith::Type&, const typename TRemoveReference::Type&> && - CThreeWayComparable::Type&, const typename TRemoveReference::Type&>::Type, OrderingType> && - requires(const TRemoveReference::Type& A, const TRemoveReference::Type& B) - { - { A <=> B } -> CThreeWayComparesAs; - { B <=> A } -> CThreeWayComparesAs; - }; +template +concept CThreeWayComparable = CWeaklyEqualityComparable && CPartiallyOrdered + && CCommonReference::Type&, const typename TRemoveReference::Type&> + && requires(const typename TRemoveReference::Type& A, const typename TRemoveReference::Type& B, + const typename TRemoveReference::Type&, const typename TRemoveReference::Type&>::Type>::Type& C) + { + { A <=> A } -> CThreeWayComparesAs; + { B <=> B } -> CThreeWayComparesAs; + { A <=> B } -> CThreeWayComparesAs; + { B <=> A } -> CThreeWayComparesAs; + { C <=> C } -> CThreeWayComparesAs; + }; template struct TCompareThreeWayResult { }; -template requires CThreeWayComparableWith +template requires CThreeWayComparable struct TCompareThreeWayResult { using Type = decltype(DeclVal::Type&>() <=> DeclVal::Type&>()); }; -template -concept CSynthThreeWayComparable = CThreeWayComparable || - requires(const TRemoveReference::Type& A, const TRemoveReference::Type& B) - { - { A < B } -> CBooleanTestable; - { B < A } -> CBooleanTestable; - }; +template +concept CSynthThreeWayComparable = CThreeWayComparable || CTotallyOrdered; -template -concept CSynthThreeWayComparableWith = CThreeWayComparableWith || - requires(const TRemoveReference::Type& A, const TRemoveReference::Type& B) - { - { A < B } -> CBooleanTestable; - { B < A } -> CBooleanTestable; - }; - -template requires CSynthThreeWayComparableWith +template requires CSynthThreeWayComparable constexpr decltype(auto) SynthThreeWayCompare(T&& LHS, U&& RHS) { - if constexpr (CThreeWayComparableWith) + if constexpr (CThreeWayComparable) { return Forward(LHS) <=> Forward(RHS); } diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index d1cf029..3853bab 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -254,7 +254,7 @@ private: template TOptional(T) -> TOptional; -template requires CWeaklyEqualityComparableWith +template requires CWeaklyEqualityComparable constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return false; @@ -262,7 +262,7 @@ constexpr bool operator==(const TOptional& LHS, const TOptional& RHS) return *LHS == *RHS; } -template requires CSynthThreeWayComparableWith +template requires CSynthThreeWayComparable constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return partial_ordering::unordered; @@ -270,7 +270,7 @@ constexpr partial_ordering operator<=>(const TOptional& LHS, const TOptional< return SynthThreeWayCompare(*LHS, *RHS); } -template requires CWeaklyEqualityComparableWith +template requires CWeaklyEqualityComparable constexpr bool operator==(const TOptional& LHS, const U& RHS) { return LHS.IsValid() ? *LHS == RHS : false; diff --git a/Redcraft.Utility/Source/Public/Templates/Tuple.h b/Redcraft.Utility/Source/Public/Templates/Tuple.h index 9b1b069..f18ea84 100644 --- a/Redcraft.Utility/Source/Public/Templates/Tuple.h +++ b/Redcraft.Utility/Source/Public/Templates/Tuple.h @@ -557,14 +557,14 @@ constexpr auto TupleCat(TTupleTypes&&... Args) else return NAMESPACE_PRIVATE::TTupleCatImpl::F(Forward(Args)...); } -template requires ((sizeof...(LHSTypes) != sizeof...(RHSTypes)) || (true && ... && CWeaklyEqualityComparableWith)) +template requires ((sizeof...(LHSTypes) != sizeof...(RHSTypes)) || (true && ... && CWeaklyEqualityComparable)) constexpr bool operator==(const TTuple& LHS, const TTuple& RHS) { if constexpr (sizeof...(LHSTypes) != sizeof...(RHSTypes)) return false; return[&LHS, &RHS](TIndexSequence) -> bool { return (true && ... && (LHS.template GetValue() == RHS.template GetValue())); } (TMakeIndexSequence()); } -template requires ((sizeof...(LHSTypes) == sizeof...(RHSTypes)) && (true && ... && (CSynthThreeWayComparableWith))) +template requires ((sizeof...(LHSTypes) == sizeof...(RHSTypes)) && (true && ... && (CSynthThreeWayComparable))) constexpr typename TCommonComparisonCategory::Type...>::Type operator<=>(const TTuple& LHS, const TTuple& RHS) { using R = typename TCommonComparisonCategory::Type...>::Type; diff --git a/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h b/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h deleted file mode 100644 index 15c26e3..0000000 --- a/Redcraft.Utility/Source/Public/TypeTraits/BitwiseOperations.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include "CoreTypes.h" -#include "TypeTraits/PrimaryType.h" -#include "TypeTraits/HelperClasses.h" -#include "TypeTraits/CompositeType.h" -#include "TypeTraits/Miscellaneous.h" -#include "TypeTraits/SupportedOperations.h" - -NAMESPACE_REDCRAFT_BEGIN -NAMESPACE_MODULE_BEGIN(Redcraft) -NAMESPACE_MODULE_BEGIN(Utility) - -// Assume that all operands of bitwise operations have the same size - -// Specialize these template classes for user-defined types -template struct TIsZeroConstructible; -template struct TIsBitwiseConstructible; -template struct TIsBitwiseRelocatable; -template struct TIsBitwiseComparable; - -// Normal use of these concepts -template concept CZeroConstructible = TIsZeroConstructible::Value; -template concept CBitwiseConstructible = TIsBitwiseConstructible::Value; -template concept CBitwiseRelocatable = TIsBitwiseRelocatable::Value; -template concept CBitwiseComparable = TIsBitwiseComparable::Value; - -// Default constructible enum, arithmetic and pointer are zero constructible -template struct TIsZeroConstructible : TBoolConstant && (CEnum || CArithmetic || CPointer)> { }; - -// Constructing a const T is the same as constructing a T -template struct TIsZeroConstructible : TIsZeroConstructible { }; - -// T can always be bitwise constructed from itself if it is trivially copy constructible -template struct TIsBitwiseConstructible : TBoolConstant ? CTriviallyCopyConstructible : false> { }; - -// Constructing a const T is the same as constructing a T -template struct TIsBitwiseConstructible : TIsBitwiseConstructible { }; - -// Const pointers can be bitwise constructed from non-const pointers -template struct TIsBitwiseConstructible : FTrue { }; - -// Unsigned types can be bitwise converted to their signed equivalents, and vice versa -template <> struct TIsBitwiseConstructible : FTrue { }; -template <> struct TIsBitwiseConstructible< int8, uint8> : FTrue { }; -template <> struct TIsBitwiseConstructible : FTrue { }; -template <> struct TIsBitwiseConstructible< int16, uint16> : FTrue { }; -template <> struct TIsBitwiseConstructible : FTrue { }; -template <> struct TIsBitwiseConstructible< int32, uint32> : FTrue { }; -template <> struct TIsBitwiseConstructible : FTrue { }; -template <> struct TIsBitwiseConstructible< int64, uint64> : FTrue { }; - -// WARNING: T is bitwise relocatable from itself by default -// T is bitwise relocatable from U, if U is trivially destructible and can be constructed bitwise to T -template struct TIsBitwiseRelocatable : TBoolConstant ? true : CTriviallyDestructible && CBitwiseConstructible> { }; - -// Constructing a const T is the same as constructing a T -template struct TIsBitwiseRelocatable : TIsBitwiseRelocatable { }; - -// Enum, arithmetic and pointer are zero constructible -template struct TIsBitwiseComparable : TBoolConstant || CArithmetic || CPointer> { }; - -// Constructing a const T is the same as constructing a T -template struct TIsBitwiseComparable : TIsBitwiseComparable { }; - -NAMESPACE_MODULE_END(Utility) -NAMESPACE_MODULE_END(Redcraft) -NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h b/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h index ab1f406..b7f5b7d 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/BooleanTestable.h @@ -9,8 +9,8 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template -concept CBooleanTestable = CConvertibleTo && - requires(T && B) { { !Forward(B) } -> CConvertibleTo; }; +concept CBooleanTestable = CConvertibleTo + && requires(T && B) { { !Forward(B) } -> CConvertibleTo; }; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Common.h b/Redcraft.Utility/Source/Public/TypeTraits/Common.h index e505079..f07652a 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Common.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Common.h @@ -24,30 +24,16 @@ NAMESPACE_PRIVATE_END template struct TCommonType : TConditional, NAMESPACE_PRIVATE::TCommonType, NAMESPACE_PRIVATE::FNoopStruct>::Type { }; template struct TCommonReference : TConditional, NAMESPACE_PRIVATE::TCommonReference, NAMESPACE_PRIVATE::FNoopStruct>::Type { }; -template -concept CCommonReferenceWith = - requires - { - typename TCommonReference::Type; - typename TCommonReference::Type; - } && - CSameAs::Type, typename TCommonReference::Type> && - CConvertibleTo::Type>&& - CConvertibleTo::Type>; +template +concept CCommonReference = + requires { typename TCommonReference::Type; } + && (true && ... && CConvertibleTo::Type>); -template -concept CCommonWith = - requires - { - typename TCommonType::Type; - typename TCommonType::Type; - requires CSameAs::Type, typename TCommonType::Type>; - static_cast::Type>(DeclVal()); - static_cast::Type>(DeclVal()); - } && - CCommonReferenceWith && - CCommonReferenceWith::Type&, typename TCommonReference::Type> && - CSameAs::Type, typename TCommonReference::Type>; +template +concept CCommonType = + requires { typename TCommonType::Type; } + && (true && ... && CConstructibleFrom::Type, Ts&&>) + && CCommonReference && CCommonReference::Type&, typename TCommonReference::Type>; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h b/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h index b6ba151..d967fc3 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Comparable.h @@ -9,8 +9,8 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template -concept CWeaklyEqualityComparableWith = +template +concept CWeaklyEqualityComparable = requires(const typename TRemoveReference::Type& A, const typename TRemoveReference::Type& B) { { A == B } -> CBooleanTestable; @@ -19,19 +19,13 @@ concept CWeaklyEqualityComparableWith = { B != A } -> CBooleanTestable; }; -template -concept CEqualityComparable = CWeaklyEqualityComparableWith; +template +concept CEqualityComparable = CWeaklyEqualityComparable && CWeaklyEqualityComparable && CWeaklyEqualityComparable + && CCommonReference::Type&, const typename TRemoveReference::Type&> + && CWeaklyEqualityComparable::Type&, const typename TRemoveReference::Type&>::Type>; -template -concept CEqualityComparableWith = - CEqualityComparable && - CEqualityComparable && - CWeaklyEqualityComparableWith && - CCommonReferenceWith::Type&, const typename TRemoveReference::Type&> && - CEqualityComparable::Type&, const typename TRemoveReference::Type&>::Type>; - -template -concept CPartiallyOrderedWith = +template +concept CPartiallyOrdered = requires(const typename TRemoveReference::Type& A, const typename TRemoveReference::Type& B) { { A < B } -> CBooleanTestable; @@ -44,15 +38,13 @@ concept CPartiallyOrderedWith = { B >= A } -> CBooleanTestable; }; -template -concept CTotallyOrdered = CEqualityComparable && CPartiallyOrderedWith; - -template -concept CTotallyOrderedWith = - CTotallyOrdered && CTotallyOrdered && - CPartiallyOrderedWith && - CEqualityComparableWith && - CTotallyOrdered::Type&, const typename TRemoveReference::Type&>::Type>; +template +concept CTotallyOrdered = + CPartiallyOrdered && CPartiallyOrdered + && CEqualityComparable && CEqualityComparable + && CPartiallyOrdered && CEqualityComparable + && CPartiallyOrdered::Type&, const typename TRemoveReference::Type&>::Type> + && CEqualityComparable::Type&, const typename TRemoveReference::Type&>::Type>; NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Object.h b/Redcraft.Utility/Source/Public/TypeTraits/Object.h index 92ea2e3..9ad5d36 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Object.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Object.h @@ -11,16 +11,15 @@ NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) template -concept CMovable = - CObject && - CMoveConstructible && - CMoveAssignable && - CSwappable; +concept CMovable = CObject + && CMoveConstructible + && CMoveAssignable + && CSwappable; template -concept CCopyable = CMovable && - CCopyConstructible && - CCopyAssignable; +concept CCopyable = CMovable + && CCopyConstructible + && CCopyAssignable; template concept CSemiregular = CCopyable && CDefaultConstructible; diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Swappable.h b/Redcraft.Utility/Source/Public/TypeTraits/Swappable.h index b61512c..61a977e 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Swappable.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Swappable.h @@ -8,21 +8,17 @@ NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) -template -concept CSwappable = requires(T& A, T& B) { Swap(A, B); }; - -template -concept CSwappableWith = CCommonReferenceWith && - requires(T&& A, U&& B) +template +concept CSwappable = CCommonReference && + requires(T& A, U& B) { - Swap(Forward(A), Forward(A)); - Swap(Forward(B), Forward(B)); - Swap(Forward(A), Forward(B)); - Swap(Forward(B), Forward(A)); + Swap(A, A); + Swap(B, B); + Swap(A, B); + Swap(B, A); }; -//template concept CNothrowSwappable; -//template concept CNothrowSwappableWith; +//template concept CNothrowSwappable; 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 bec9678..0bbe4b4 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h @@ -12,7 +12,6 @@ #include "TypeTraits/Common.h" #include "TypeTraits/CopyQualifiers.h" #include "TypeTraits/InPlaceSpecialization.h" -#include "TypeTraits/BitwiseOperations.h" #include "TypeTraits/BooleanTestable.h" #include "TypeTraits/Object.h" #include "TypeTraits/Comparable.h"