refactor(typetraits): replaces template class type traits with concepts for TypeTraits/SupportedOperations.h

This commit is contained in:
_Redstone_c_ 2022-05-16 22:42:17 +08:00
parent c316b8f190
commit 413762a90a
16 changed files with 213 additions and 261 deletions

View File

@ -58,12 +58,6 @@ void TestConcepts()
always_check(!(CSameAs<int32, int64>));
always_check((CSameAs<int32, int32>));
// Destructible.h
always_check(CDestructible<FTestStructS>);
always_check(CDestructible<FTestStructT>);
always_check(!CDestructible<FTestStructU>);
// Derived.h
always_check(!(CDerivedFrom<FTestStructH, FTestStructD>));
@ -78,27 +72,6 @@ void TestConcepts()
always_check(!(CConvertibleTo<FTestStructE*, FTestStructH*>));
always_check((CConvertibleTo<FTestStructW, FTestStructV>));
// Constructible.h
always_check((CConstructibleFrom<FTestStructJ>));
always_check((CConstructibleFrom<FTestStructK>));
always_check(!(CConstructibleFrom<FTestStructI, int32>));
always_check((CConstructibleFrom<FTestStructI, FTestStructI&>));
always_check((CConstructibleFrom<FTestStructI, int32, double>));
always_check(!CDefaultInitializable<FTestStructI>);
always_check(CDefaultInitializable<FTestStructJ>);
always_check(CDefaultInitializable<FTestStructK>);
always_check(!CDefaultInitializable<FTestStructL>);
always_check(CMoveConstructible<FTestStructP>);
always_check(CMoveConstructible<FTestStructQ>);
always_check(!CMoveConstructible<FTestStructR>);
always_check(CCopyConstructible<FTestStructM>);
always_check(CCopyConstructible<FTestStructN>);
always_check(!CCopyConstructible<FTestStructO>);
// BooleanTestable.h
always_check(CBooleanTestable<bool>);
@ -106,14 +79,6 @@ void TestConcepts()
always_check(CBooleanTestable<float>);
always_check(!CBooleanTestable<FTestStructA>);
// Assignable.h
always_check((CAssignableFrom<int32&, int64>));
always_check((CAssignableFrom<int32&, int32>));
always_check((CAssignableFrom<int32&, int8>));
always_check(!(CAssignableFrom<FTestStructI&, int32>));
always_check(!(CAssignableFrom<FTestStructA&, void>));
// Common.h
always_check((CCommonWith<int32, int32>));

View File

@ -744,20 +744,20 @@ void TestTuple()
Temp.Fifteenth = 0;
Temp.Sixteenth = 0;
always_check(TIsDefaultConstructible<Type>::Value);
always_check(TIsTriviallyDefaultConstructible<Type>::Value);
always_check(TIsConstructible<Type>::Value);
always_check(TIsTriviallyConstructible<Type>::Value);
always_check(TIsCopyConstructible<Type>::Value);
always_check(TIsTriviallyCopyConstructible<Type>::Value);
always_check(TIsMoveConstructible<Type>::Value);
always_check(TIsTriviallyMoveConstructible<Type>::Value);
always_check(TIsCopyAssignable<Type>::Value);
always_check(TIsTriviallyCopyAssignable<Type>::Value);
always_check(TIsMoveAssignable<Type>::Value);
always_check(TIsTriviallyMoveAssignable<Type>::Value);
always_check(TIsDestructible<Type>::Value);
always_check(TIsTriviallyDestructible<Type>::Value);
always_check(CDefaultConstructible<Type>);
always_check(CTriviallyDefaultConstructible<Type>);
always_check(CConstructible<Type>);
always_check(CTriviallyConstructible<Type>);
always_check(CCopyConstructible<Type>);
always_check(CTriviallyCopyConstructible<Type>);
always_check(CMoveConstructible<Type>);
always_check(CTriviallyMoveConstructible<Type>);
always_check(CCopyAssignable<Type>);
always_check(CTriviallyCopyAssignable<Type>);
always_check(CMoveAssignable<Type>);
always_check(CTriviallyMoveAssignable<Type>);
always_check(CDestructible<Type>);
always_check(CTriviallyDestructible<Type>);
}
{

View File

@ -230,74 +230,74 @@ void TestTypeTraits()
// SupportedOperations.h
always_check(!TIsDefaultConstructible<FTestStructI>::Value);
always_check(TIsDefaultConstructible<FTestStructJ>::Value);
always_check(TIsDefaultConstructible<FTestStructK>::Value);
always_check(!TIsDefaultConstructible<FTestStructL>::Value);
always_check(!CDefaultConstructible<FTestStructI>);
always_check(CDefaultConstructible<FTestStructJ>);
always_check(CDefaultConstructible<FTestStructK>);
always_check(!CDefaultConstructible<FTestStructL>);
always_check(!TIsTriviallyDefaultConstructible<FTestStructI>::Value);
always_check(!TIsTriviallyDefaultConstructible<FTestStructJ>::Value);
always_check(TIsTriviallyDefaultConstructible<FTestStructK>::Value);
always_check(!TIsTriviallyDefaultConstructible<FTestStructL>::Value);
always_check(!CTriviallyDefaultConstructible<FTestStructI>);
always_check(!CTriviallyDefaultConstructible<FTestStructJ>);
always_check(CTriviallyDefaultConstructible<FTestStructK>);
always_check(!CTriviallyDefaultConstructible<FTestStructL>);
always_check(!(TIsConstructible<FTestStructI, int32>::Value));
always_check((TIsConstructible<FTestStructI, FTestStructI&>::Value));
always_check((TIsConstructible<FTestStructI, int32, double>::Value));
always_check(!(CConstructible<FTestStructI, int32>));
always_check((CConstructible<FTestStructI, FTestStructI&>));
always_check((CConstructible<FTestStructI, int32, double>));
always_check(!(TIsTriviallyConstructible<FTestStructI, int32>::Value));
always_check((TIsTriviallyConstructible<FTestStructI, FTestStructI&>::Value));
always_check(!(TIsTriviallyConstructible<FTestStructI, int32, double>::Value));
always_check(!(CTriviallyConstructible<FTestStructI, int32>));
always_check((CTriviallyConstructible<FTestStructI, FTestStructI&>));
always_check(!(CTriviallyConstructible<FTestStructI, int32, double>));
always_check(TIsCopyConstructible<FTestStructM>::Value);
always_check(TIsCopyConstructible<FTestStructN>::Value);
always_check(!TIsCopyConstructible<FTestStructO>::Value);
always_check(CCopyConstructible<FTestStructM>);
always_check(CCopyConstructible<FTestStructN>);
always_check(!CCopyConstructible<FTestStructO>);
always_check(!TIsTriviallyCopyConstructible<FTestStructM>::Value);
always_check(TIsTriviallyCopyConstructible<FTestStructN>::Value);
always_check(!TIsTriviallyCopyConstructible<FTestStructO>::Value);
always_check(!CTriviallyCopyConstructible<FTestStructM>);
always_check(CTriviallyCopyConstructible<FTestStructN>);
always_check(!CTriviallyCopyConstructible<FTestStructO>);
always_check(TIsMoveConstructible<FTestStructP>::Value);
always_check(TIsMoveConstructible<FTestStructQ>::Value);
always_check(!TIsMoveConstructible<FTestStructR>::Value);
always_check(CMoveConstructible<FTestStructP>);
always_check(CMoveConstructible<FTestStructQ>);
always_check(!CMoveConstructible<FTestStructR>);
always_check(!TIsTriviallyMoveConstructible<FTestStructP>::Value);
always_check(TIsTriviallyMoveConstructible<FTestStructQ>::Value);
always_check(!TIsTriviallyMoveConstructible<FTestStructR>::Value);
always_check(!CTriviallyMoveConstructible<FTestStructP>);
always_check(CTriviallyMoveConstructible<FTestStructQ>);
always_check(!CTriviallyMoveConstructible<FTestStructR>);
always_check(!(TIsAssignable<FTestStructI, FTestStructH>::Value));
always_check((TIsAssignable<FTestStructI, FTestStructI&>::Value));
always_check((TIsAssignable<FTestStructI, int32>::Value));
always_check(!(CAssignable<FTestStructI, FTestStructH>));
always_check((CAssignable<FTestStructI, FTestStructI&>));
always_check((CAssignable<FTestStructI, int32>));
always_check(!(TIsTriviallyAssignable<FTestStructI, FTestStructH>::Value));
always_check((TIsTriviallyAssignable<FTestStructI, FTestStructI&>::Value));
always_check(!(TIsTriviallyAssignable<FTestStructI, int32>::Value));
always_check(!(CTriviallyAssignable<FTestStructI, FTestStructH>));
always_check((CTriviallyAssignable<FTestStructI, FTestStructI&>));
always_check(!(CTriviallyAssignable<FTestStructI, int32>));
always_check(TIsCopyAssignable<FTestStructM>::Value);
always_check(TIsCopyAssignable<FTestStructN>::Value);
always_check(!TIsCopyAssignable<FTestStructO>::Value);
always_check(CCopyAssignable<FTestStructM>);
always_check(CCopyAssignable<FTestStructN>);
always_check(!CCopyAssignable<FTestStructO>);
always_check(!TIsTriviallyCopyAssignable<FTestStructM>::Value);
always_check(TIsTriviallyCopyAssignable<FTestStructN>::Value);
always_check(!TIsTriviallyCopyAssignable<FTestStructO>::Value);
always_check(!CTriviallyCopyAssignable<FTestStructM>);
always_check(CTriviallyCopyAssignable<FTestStructN>);
always_check(!CTriviallyCopyAssignable<FTestStructO>);
always_check(TIsMoveAssignable<FTestStructP>::Value);
always_check(TIsMoveAssignable<FTestStructQ>::Value);
always_check(!TIsMoveAssignable<FTestStructR>::Value);
always_check(CMoveAssignable<FTestStructP>);
always_check(CMoveAssignable<FTestStructQ>);
always_check(!CMoveAssignable<FTestStructR>);
always_check(!TIsTriviallyMoveAssignable<FTestStructP>::Value);
always_check(TIsTriviallyMoveAssignable<FTestStructQ>::Value);
always_check(!TIsTriviallyMoveAssignable<FTestStructR>::Value);
always_check(!CTriviallyMoveAssignable<FTestStructP>);
always_check(CTriviallyMoveAssignable<FTestStructQ>);
always_check(!CTriviallyMoveAssignable<FTestStructR>);
always_check(TIsDestructible<FTestStructS>::Value);
always_check(TIsDestructible<FTestStructT>::Value);
always_check(!TIsDestructible<FTestStructU>::Value);
always_check(CDestructible<FTestStructS>);
always_check(CDestructible<FTestStructT>);
always_check(!CDestructible<FTestStructU>);
always_check(!TIsTriviallyDestructible<FTestStructS>::Value);
always_check(TIsTriviallyDestructible<FTestStructT>::Value);
always_check(!TIsTriviallyDestructible<FTestStructU>::Value);
always_check(!CTriviallyDestructible<FTestStructS>);
always_check(CTriviallyDestructible<FTestStructT>);
always_check(!CTriviallyDestructible<FTestStructU>);
always_check(!THasVirtualDestructor<FTestStructT>::Value);
always_check(THasVirtualDestructor<FTestStructV>::Value);
always_check(!CVirtualDestructible<FTestStructT>);
always_check(CVirtualDestructible<FTestStructV>);
// Miscellaneous.h

View File

@ -12,20 +12,11 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename T, typename... Args>
concept CConstructibleFrom = CDestructible<T> && TIsConstructible<T, Args...>::Value;
concept CConstructibleFrom = CDestructible<T> && CConstructible<T, Args...>;
template <typename T>
concept CDefaultInitializable = CConstructibleFrom<T> && requires { T{}; ::new(static_cast<void*>(nullptr)) T; };
template <typename T>
concept CMoveConstructible = CConstructibleFrom<T, T> && CConvertibleTo<T, T>;
template <typename T>
concept CCopyConstructible = CMoveConstructible<T> &&
CConstructibleFrom<T, T&> && CConvertibleTo<T&, T> &&
CConstructibleFrom<T, const T&> && CConvertibleTo<const T&, T> &&
CConstructibleFrom<T, const T> && CConvertibleTo<const T, T>;
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)
NAMESPACE_REDCRAFT_END

View File

@ -7,9 +7,6 @@ NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename T>
concept CDestructible = TIsDestructible<T>::Value;
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)
NAMESPACE_REDCRAFT_END

View File

@ -13,7 +13,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
NAMESPACE_BEGIN(Memory)
template <typename ElementType>
requires TIsDefaultConstructible<ElementType>::Value
requires CDefaultConstructible<ElementType>
FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1)
{
if constexpr (TIsZeroConstructible<ElementType>::Value)
@ -33,7 +33,7 @@ FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1)
}
template <typename DestinationElementType, typename SourceElementType>
requires TIsConstructible<DestinationElementType, const SourceElementType&>::Value
requires CConstructible<DestinationElementType, const SourceElementType&>
FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElementType* Source, size_t Count = 1)
{
if constexpr (TIsBitwiseConstructible<DestinationElementType, const SourceElementType>::Value)
@ -53,10 +53,10 @@ FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElem
}
template <typename ElementType>
requires TIsCopyConstructible<ElementType>::Value
requires CCopyConstructible<ElementType>
FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Source, size_t Count = 1)
{
if constexpr (TIsTriviallyCopyConstructible<ElementType>::Value)
if constexpr (CTriviallyCopyConstructible<ElementType>)
{
Memory::Memcpy(Destination, Source, sizeof(ElementType) * Count);
}
@ -73,10 +73,10 @@ FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Sour
}
template <typename ElementType>
requires TIsMoveConstructible<ElementType>::Value
requires CMoveConstructible<ElementType>
FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, size_t Count = 1)
{
if constexpr (TIsTriviallyMoveConstructible<ElementType>::Value)
if constexpr (CTriviallyMoveConstructible<ElementType>)
{
Memory::Memmove(Destination, Source, sizeof(ElementType) * Count);
}
@ -93,7 +93,7 @@ FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, si
}
template <typename DestinationElementType, typename SourceElementType>
requires TIsConstructible<DestinationElementType, SourceElementType&&>::Value && TIsDestructible<SourceElementType>::Value
requires CConstructible<DestinationElementType, SourceElementType&&> && CDestructible<SourceElementType>
FORCEINLINE void RelocateConstruct(DestinationElementType* Destination, SourceElementType* Source, size_t Count = 1)
{
if constexpr (TIsBitwiseRelocatable<DestinationElementType, SourceElementType>::Value)
@ -115,10 +115,10 @@ FORCEINLINE void RelocateConstruct(DestinationElementType* Destination, SourceEl
}
template <typename ElementType>
requires TIsDestructible<ElementType>::Value
requires CDestructible<ElementType>
FORCEINLINE void Destruct(ElementType* Element, size_t Count = 1)
{
if constexpr (!TIsTriviallyDestructible<ElementType>::Value)
if constexpr (!CTriviallyDestructible<ElementType>)
{
while (Count)
{
@ -130,10 +130,10 @@ FORCEINLINE void Destruct(ElementType* Element, size_t Count = 1)
}
template <typename ElementType>
requires TIsCopyAssignable<ElementType>::Value
requires CCopyAssignable<ElementType>
FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source, size_t Count = 1)
{
if constexpr (TIsTriviallyCopyAssignable<ElementType>::Value)
if constexpr (CTriviallyCopyAssignable<ElementType>)
{
Memory::Memcpy(Destination, Source, sizeof(ElementType) * Count);
}
@ -150,10 +150,10 @@ FORCEINLINE void CopyAssign(ElementType* Destination, const ElementType* Source,
}
template <typename ElementType>
requires TIsMoveAssignable<ElementType>::Value
requires CMoveAssignable<ElementType>
FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_t Count = 1)
{
if constexpr (TIsTriviallyCopyConstructible<ElementType>::Value)
if constexpr (CTriviallyCopyConstructible<ElementType>)
{
Memory::Memmove(Destination, Source, sizeof(ElementType) * Count);
}

View File

@ -68,8 +68,8 @@ struct alignas(InlineAlignment) TAny
}
}
template <typename T, typename... Types> requires TIsDestructible<typename TDecay<T>::Type>::Value
&& TIsConstructible<typename TDecay<T>::Type, Types...>::Value
template <typename T, typename... Types> requires CDestructible<typename TDecay<T>::Type>
&& CConstructible<typename TDecay<T>::Type, Types...>
FORCEINLINE explicit TAny(TInPlaceType<T>, Types&&... Args)
{
using SelectedType = typename TDecay<T>::Type;
@ -77,7 +77,7 @@ struct alignas(InlineAlignment) TAny
}
template <typename T> requires (!TIsSame<typename TDecay<T>::Type, TAny>::Value) && (!TIsTInPlaceType<typename TDecay<T>::Type>::Value)
&& TIsDestructible<typename TDecay<T>::Type>::Value && TIsConstructible<typename TDecay<T>::Type, T&&>::Value
&& CDestructible<typename TDecay<T>::Type> && CConstructible<typename TDecay<T>::Type, T&&>
FORCEINLINE TAny(T&& InValue) : TAny(InPlaceType<typename TDecay<T>::Type>, Forward<T>(InValue))
{ }
@ -185,7 +185,7 @@ struct alignas(InlineAlignment) TAny
}
template <typename T> requires (!TIsSame<typename TDecay<T>::Type, TAny>::Value) && (!TIsTInPlaceType<typename TDecay<T>::Type>::Value)
&& TIsDestructible<typename TDecay<T>::Type>::Value && TIsConstructible<typename TDecay<T>::Type, T&&>::Value
&& CDestructible<typename TDecay<T>::Type> && CConstructible<typename TDecay<T>::Type, T&&>
FORCEINLINE TAny& operator=(T&& InValue)
{
using SelectedType = typename TDecay<T>::Type;
@ -203,8 +203,8 @@ struct alignas(InlineAlignment) TAny
return *this;
}
template <typename T, typename... Types> requires TIsDestructible<typename TDecay<T>::Type>::Value
&& TIsConstructible<typename TDecay<T>::Type, T&&>::Value
template <typename T, typename... Types> requires CDestructible<typename TDecay<T>::Type>
&& CConstructible<typename TDecay<T>::Type, T&&>
FORCEINLINE typename TDecay<T>::Type& Emplace(Types&&... Args)
{
ResetImpl();
@ -221,22 +221,22 @@ struct alignas(InlineAlignment) TAny
template <typename T> constexpr bool HoldsAlternative() const { return IsValid() ? GetTypeInfo() == typeid(T) : false; }
template <typename T> requires TIsDestructible<typename TDecay<T>::Type>::Value
template <typename T> requires CDestructible<typename TDecay<T>::Type>
constexpr T& GetValue() & { checkf(HoldsAlternative<T>(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(GetAllocation()); }
template <typename T> requires TIsDestructible<typename TDecay<T>::Type>::Value
template <typename T> requires CDestructible<typename TDecay<T>::Type>
constexpr T&& GetValue() && { checkf(HoldsAlternative<T>(), 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< T*>(GetAllocation())); }
template <typename T> requires TIsDestructible<typename TDecay<T>::Type>::Value
template <typename T> requires CDestructible<typename TDecay<T>::Type>
constexpr const T& GetValue() const& { checkf(HoldsAlternative<T>(), TEXT("It is an error to call GetValue() on an wrong TAny. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast<const T*>(GetAllocation()); }
template <typename T> requires TIsDestructible<typename TDecay<T>::Type>::Value
template <typename T> requires CDestructible<typename TDecay<T>::Type>
constexpr const T&& GetValue() const&& { checkf(HoldsAlternative<T>(), 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<const T*>(GetAllocation())); }
template <typename T> requires TIsSame<T, typename TDecay<T>::Type>::Value&& TIsDestructible<typename TDecay<T>::Type>::Value
template <typename T> requires TIsSame<T, typename TDecay<T>::Type>::Value&& CDestructible<typename TDecay<T>::Type>
constexpr T& Get( T& DefaultValue) & { return HoldsAlternative<T>() ? GetValue<T>() : DefaultValue; }
template <typename T> requires TIsSame<T, typename TDecay<T>::Type>::Value&& TIsDestructible<typename TDecay<T>::Type>::Value
template <typename T> requires TIsSame<T, typename TDecay<T>::Type>::Value&& CDestructible<typename TDecay<T>::Type>
constexpr const T& Get(const T& DefaultValue) const& { return HoldsAlternative<T>() ? GetValue<T>() : DefaultValue; }
FORCEINLINE void Reset()

View File

@ -52,8 +52,8 @@ NAMESPACE_PRIVATE_END
#endif
template <typename T, bool bIsRef = false> requires CTriviallyCopyable<T>
&& TIsCopyConstructible<T>::Value && TIsMoveConstructible<T>::Value
&& TIsCopyAssignable<T>::Value && TIsMoveAssignable<T>::Value
&& CCopyConstructible<T> && CMoveConstructible<T>
&& CCopyAssignable<T> && CMoveAssignable<T>
struct TAtomic : public FSingleton
{
protected:

View File

@ -107,10 +107,10 @@ public:
FORCEINLINE const type_info& TargetType() const requires (!bIsRef) { return IsValid() ? Storage.GetTypeInfo() : typeid(void); };
template <typename T> FORCEINLINE T& Target() & requires (!bIsRef) && TIsDestructible<typename TDecay<T>::Type>::Value { return static_cast< StorageType& >(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE T&& Target() && requires (!bIsRef) && TIsDestructible<typename TDecay<T>::Type>::Value { return static_cast< StorageType&&>(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE const T& Target() const& requires (!bIsRef) && TIsDestructible<typename TDecay<T>::Type>::Value { return static_cast<const StorageType& >(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE const T&& Target() const&& requires (!bIsRef) && TIsDestructible<typename TDecay<T>::Type>::Value { return static_cast<const StorageType&&>(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE T& Target() & requires (!bIsRef) && CDestructible<typename TDecay<T>::Type> { return static_cast< StorageType& >(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE T&& Target() && requires (!bIsRef) && CDestructible<typename TDecay<T>::Type> { return static_cast< StorageType&&>(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE const T& Target() const& requires (!bIsRef) && CDestructible<typename TDecay<T>::Type> { return static_cast<const StorageType& >(Storage).template GetValue<T>(); }
template <typename T> FORCEINLINE const T&& Target() const&& requires (!bIsRef) && CDestructible<typename TDecay<T>::Type> { return static_cast<const StorageType&&>(Storage).template GetValue<T>(); }
constexpr void Swap(TFunctionImpl& InValue) requires (!bIsRef)
{
@ -296,7 +296,7 @@ public:
template <typename T> requires (!TIsTInPlaceType<typename TDecay<T>::Type>::Value)
&& (!TIsTFunctionRef<typename TDecay<T>::Type>::Value) && (!TIsTFunction<typename TDecay<T>::Type>::Value) && (!TIsTUniqueFunction<typename TDecay<T>::Type>::Value)
&& TIsConstructible<typename TDecay<T>::Type, T&&>::Value && TIsCopyConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, T&&> && CCopyConstructible<typename TDecay<T>::Type>
&& NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
FORCEINLINE TFunction(T&& InValue)
{
@ -306,7 +306,7 @@ public:
}
template <typename T, typename... ArgTypes> requires NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
&& TIsConstructible<typename TDecay<T>::Type, ArgTypes...>::Value && TIsCopyConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, ArgTypes...> && CCopyConstructible<typename TDecay<T>::Type>
FORCEINLINE TFunction(TInPlaceType<T>, ArgTypes&&... Args)
{
using DecayedType = typename TDecay<T>::Type;
@ -317,7 +317,7 @@ public:
template <typename T> requires NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
&& (!TIsTFunctionRef<typename TDecay<T>::Type>::Value) && (!TIsTFunction<typename TDecay<T>::Type>::Value) && (!TIsTUniqueFunction<typename TDecay<T>::Type>::Value)
&& TIsConstructible<typename TDecay<T>::Type, T&&>::Value && TIsCopyConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, T&&> && CCopyConstructible<typename TDecay<T>::Type>
FORCEINLINE TFunction& operator=(T&& InValue)
{
using DecayedType = typename TDecay<T>::Type;
@ -329,7 +329,7 @@ public:
}
template <typename T, typename... ArgTypes> requires NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
&& TIsConstructible<typename TDecay<T>::Type, ArgTypes...>::Value&& TIsCopyConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, ArgTypes...>&& CCopyConstructible<typename TDecay<T>::Type>
FORCEINLINE typename TDecay<T>::Type& Emplace(ArgTypes&&... Args)
{
using DecayedType = typename TDecay<T>::Type;
@ -399,7 +399,7 @@ public:
template <typename T> requires (!TIsTInPlaceType<typename TDecay<T>::Type>::Value)
&& (!TIsTFunctionRef<typename TDecay<T>::Type>::Value) && (!TIsTFunction<typename TDecay<T>::Type>::Value) && (!TIsTUniqueFunction<typename TDecay<T>::Type>::Value)
&& TIsConstructible<typename TDecay<T>::Type, T&&>::Value && TIsMoveConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, T&&> && CMoveConstructible<typename TDecay<T>::Type>
&& NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
FORCEINLINE TUniqueFunction(T&& InValue)
{
@ -409,7 +409,7 @@ public:
}
template <typename T, typename... ArgTypes> requires NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
&& TIsConstructible<typename TDecay<T>::Type, ArgTypes...>::Value && TIsMoveConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, ArgTypes...> && CMoveConstructible<typename TDecay<T>::Type>
FORCEINLINE TUniqueFunction(TInPlaceType<T>, ArgTypes&&... Args)
{
using DecayedType = typename TDecay<T>::Type;
@ -420,7 +420,7 @@ public:
template <typename T> requires NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
&& (!TIsTFunctionRef<typename TDecay<T>::Type>::Value) && (!TIsTFunction<typename TDecay<T>::Type>::Value) && (!TIsTUniqueFunction<typename TDecay<T>::Type>::Value)
&& TIsConstructible<typename TDecay<T>::Type, T&&>::Value&& TIsMoveConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, T&&>&& CMoveConstructible<typename TDecay<T>::Type>
FORCEINLINE TUniqueFunction& operator=(T&& InValue)
{
using DecayedType = typename TDecay<T>::Type;
@ -432,7 +432,7 @@ public:
}
template <typename T, typename... ArgTypes> requires NAMESPACE_PRIVATE::TIsInvocableSignature<F, typename TDecay<T>::Type>::Value
&& TIsConstructible<typename TDecay<T>::Type, ArgTypes...>::Value&& TIsMoveConstructible<typename TDecay<T>::Type>::Value
&& CConstructible<typename TDecay<T>::Type, ArgTypes...>&& CMoveConstructible<typename TDecay<T>::Type>
FORCEINLINE typename TDecay<T>::Type& Emplace(ArgTypes&&... Args)
{
using DecayedType = typename TDecay<T>::Type;

View File

@ -12,25 +12,25 @@ NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename OptionalType> requires TIsDestructible<OptionalType>::Value
template <typename OptionalType> requires CDestructible<OptionalType>
struct TOptional
{
private:
template <typename T>
struct TAllowUnwrapping : TBoolConstant<!(
TIsConstructible<OptionalType, TOptional<T>& >::Value
|| TIsConstructible<OptionalType, const TOptional<T>& >::Value
|| TIsConstructible<OptionalType, TOptional<T>&&>::Value
|| TIsConstructible<OptionalType, const TOptional<T>&&>::Value
CConstructible<OptionalType, TOptional<T>& >
|| CConstructible<OptionalType, const TOptional<T>& >
|| CConstructible<OptionalType, TOptional<T>&&>
|| CConstructible<OptionalType, const TOptional<T>&&>
|| TIsConvertible< TOptional<T>&, OptionalType>::Value
|| TIsConvertible<const TOptional<T>&, OptionalType>::Value
|| TIsConvertible< TOptional<T>&&, OptionalType>::Value
|| TIsConvertible<const TOptional<T>&&, OptionalType>::Value
|| TIsAssignable<OptionalType&, TOptional<T>& >::Value
|| TIsAssignable<OptionalType&, const TOptional<T>& >::Value
|| TIsAssignable<OptionalType&, TOptional<T>&&>::Value
|| TIsAssignable<OptionalType&, const TOptional<T>&&>::Value
|| CAssignable<OptionalType&, TOptional<T>& >
|| CAssignable<OptionalType&, const TOptional<T>& >
|| CAssignable<OptionalType&, TOptional<T>&&>
|| CAssignable<OptionalType&, const TOptional<T>&&>
)> { };
public:
@ -41,39 +41,39 @@ public:
constexpr TOptional(FInvalid) : TOptional() { }
template <typename... Types> requires TIsConstructible<OptionalType, Types...>::Value
template <typename... Types> requires CConstructible<OptionalType, Types...>
constexpr explicit TOptional(FInPlace, Types&&... Args)
: bIsValid(true)
{
new(&Value) OptionalType(Forward<Types>(Args)...);
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, T&&>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, T&&>
&& (!TIsSame<typename TRemoveCVRef<T>::Type, FInPlace>::Value) && (!TIsSame<typename TRemoveCVRef<T>::Type, TOptional>::Value)
constexpr explicit (!TIsConvertible<T&&, OptionalType>::Value) TOptional(T&& InValue)
: TOptional(InPlace, Forward<T>(InValue))
{ }
constexpr TOptional(const TOptional& InValue) requires TIsCopyConstructible<OptionalType>::Value
constexpr TOptional(const TOptional& InValue) requires CCopyConstructible<OptionalType>
: bIsValid(InValue.IsValid())
{
if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue());
}
constexpr TOptional(TOptional&& InValue) requires TIsMoveConstructible<OptionalType>::Value
constexpr TOptional(TOptional&& InValue) requires CMoveConstructible<OptionalType>
: bIsValid(InValue.IsValid())
{
if (InValue.IsValid()) new(&Value) OptionalType(MoveTemp(InValue.GetValue()));
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, const T&>::Value && TAllowUnwrapping<T>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, const T&> && TAllowUnwrapping<T>::Value
constexpr explicit (!TIsConvertible<const T&, OptionalType>::Value) TOptional(const TOptional<T>& InValue)
: bIsValid(InValue.IsValid())
{
if (InValue.IsValid()) new(&Value) OptionalType(InValue.GetValue());
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, T&&>::Value && TAllowUnwrapping<T>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, T&&> && TAllowUnwrapping<T>::Value
constexpr explicit (!TIsConvertible<T&&, OptionalType>::Value) TOptional(TOptional<T>&& InValue)
: bIsValid(InValue.IsValid())
{
@ -82,10 +82,10 @@ public:
constexpr ~TOptional()
{
if constexpr (!TIsTriviallyDestructible<OptionalType>::Value) Reset();
if constexpr (!CTriviallyDestructible<OptionalType>) Reset();
}
constexpr TOptional& operator=(const TOptional& InValue) requires TIsCopyConstructible<OptionalType>::Value && TIsCopyAssignable<OptionalType>::Value
constexpr TOptional& operator=(const TOptional& InValue) requires CCopyConstructible<OptionalType> && CCopyAssignable<OptionalType>
{
if (&InValue == this) return *this;
@ -105,7 +105,7 @@ public:
return *this;
}
constexpr TOptional& operator=(TOptional&& InValue) requires TIsMoveConstructible<OptionalType>::Value && TIsMoveAssignable<OptionalType>::Value
constexpr TOptional& operator=(TOptional&& InValue) requires CMoveConstructible<OptionalType> && CMoveAssignable<OptionalType>
{
if (&InValue == this) return *this;
@ -125,7 +125,7 @@ public:
return *this;
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, const T&>::Value && TIsAssignable<OptionalType&, const T&>::Value && TAllowUnwrapping<T>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, const T&> && CAssignable<OptionalType&, const T&> && TAllowUnwrapping<T>::Value
constexpr TOptional& operator=(const TOptional<T>& InValue)
{
if (!InValue.IsValid())
@ -144,7 +144,7 @@ public:
return *this;
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, T&&>::Value && TIsAssignable<OptionalType&, T&&>::Value && TAllowUnwrapping<T>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, T&&> && CAssignable<OptionalType&, T&&> && TAllowUnwrapping<T>::Value
constexpr TOptional& operator=(TOptional<T>&& InValue)
{
if (!InValue.IsValid())
@ -163,7 +163,7 @@ public:
return *this;
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, T&&>::Value && TIsAssignable<OptionalType&, T&&>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, T&&> && CAssignable<OptionalType&, T&&>
constexpr TOptional& operator=(T&& InValue)
{
if (IsValid()) GetValue() = Forward<T>(InValue);
@ -176,7 +176,7 @@ public:
return *this;
}
template <typename... ArgTypes> requires TIsConstructible<OptionalType, ArgTypes...>::Value
template <typename... ArgTypes> requires CConstructible<OptionalType, ArgTypes...>
constexpr OptionalType& Emplace(ArgTypes&&... Args)
{
Reset();
@ -223,7 +223,7 @@ public:
return NAMESPACE_REDCRAFT::GetTypeHash(GetValue());
}
template <typename T> requires TIsMoveConstructible<OptionalType>::Value && TIsSwappable<OptionalType>::Value
template <typename T> requires CMoveConstructible<OptionalType> && TIsSwappable<OptionalType>::Value
constexpr void Swap(TOptional& InValue)
{
if (!IsValid() && !InValue.IsValid()) return;
@ -283,19 +283,19 @@ constexpr bool operator==(const TOptional<T>& LHS, FInvalid)
return !LHS.IsValid();
}
template <typename T> requires TIsDestructible<T>::Value
template <typename T> requires CDestructible<T>
constexpr TOptional<typename TDecay<T>::Type> MakeOptional(FInvalid)
{
return TOptional<typename TDecay<T>::Type>(Invalid);
}
template <typename T> requires TIsDestructible<T>::Value && TIsConstructible<T, T&&>::Value
template <typename T> requires CDestructible<T> && CConstructible<T, T&&>
constexpr TOptional<T> MakeOptional(T&& InValue)
{
return TOptional<T>(Forward<T>(InValue));
}
template <typename T, typename... Types> requires TIsDestructible<T>::Value && TIsConstructible<T, Types...>::Value
template <typename T, typename... Types> requires CDestructible<T> && CConstructible<T, Types...>
constexpr TOptional<T> MakeOptional(Types&&... Args)
{
return TOptional<T>(InPlace, Forward<T>(Args)...);

View File

@ -65,7 +65,7 @@ private:
// Optimize TOptional with these hacking
constexpr TReferenceWrapper(FInvalid) : Pointer(nullptr) { };
template <typename T> requires TIsDestructible<T>::Value friend struct TOptional;
template <typename T> requires CDestructible<T> friend struct TOptional;
};
@ -116,18 +116,18 @@ private:
template <typename T>
struct TAllowUnwrapping : TBoolConstant<!(
TIsConstructible<OptionalType, TOptional<T>& >::Value
|| TIsConstructible<OptionalType, const TOptional<T>& >::Value
|| TIsConstructible<OptionalType, TOptional<T>&&>::Value
|| TIsConstructible<OptionalType, const TOptional<T>&&>::Value
CConstructible<OptionalType, TOptional<T>& >
|| CConstructible<OptionalType, const TOptional<T>& >
|| CConstructible<OptionalType, TOptional<T>&&>
|| CConstructible<OptionalType, const TOptional<T>&&>
|| TIsConvertible< TOptional<T>&, OptionalType>::Value
|| TIsConvertible<const TOptional<T>&, OptionalType>::Value
|| TIsConvertible< TOptional<T>&&, OptionalType>::Value
|| TIsConvertible<const TOptional<T>&&, OptionalType>::Value
|| TIsAssignable<OptionalType&, TOptional<T>& >::Value
|| TIsAssignable<OptionalType&, const TOptional<T>& >::Value
|| TIsAssignable<OptionalType&, TOptional<T>&&>::Value
|| TIsAssignable<OptionalType&, const TOptional<T>&&>::Value
|| CAssignable<OptionalType&, TOptional<T>& >
|| CAssignable<OptionalType&, const TOptional<T>& >
|| CAssignable<OptionalType&, TOptional<T>&&>
|| CAssignable<OptionalType&, const TOptional<T>&&>
)> { };
public:
@ -138,12 +138,12 @@ public:
constexpr TOptional(FInvalid) : TOptional() { }
template <typename... Types> requires TIsConstructible<OptionalType, Types...>::Value
template <typename... Types> requires CConstructible<OptionalType, Types...>
constexpr explicit TOptional(FInPlace, Types&&... Args)
: Reference(Forward<Types>(Args)...)
{ }
template <typename T = OptionalType> requires TIsConstructible<OptionalType, T&&>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, T&&>
&& (!TIsSame<typename TRemoveCVRef<T>::Type, FInPlace>::Value) && (!TIsSame<typename TRemoveCVRef<T>::Type, TOptional>::Value)
constexpr explicit (!TIsConvertible<T&&, OptionalType>::Value) TOptional(T&& InValue)
: TOptional(InPlace, Forward<T>(InValue))
@ -152,7 +152,7 @@ public:
TOptional(const TOptional& InValue) = default;
TOptional(TOptional&& InValue) = default;
template <typename T = OptionalType> requires TIsConstructible<OptionalType, const T&>::Value && TAllowUnwrapping<T>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, const T&> && TAllowUnwrapping<T>::Value
constexpr explicit (!TIsConvertible<const T&, OptionalType>::Value) TOptional(const TOptional<T>& InValue)
: Reference(InValue.Reference)
{ }
@ -162,21 +162,21 @@ public:
TOptional& operator=(const TOptional& InValue) = default;
TOptional& operator=(TOptional&& InValue) = default;
template <typename T = OptionalType> requires TIsConstructible<OptionalType, const T&>::Value && TIsAssignable<OptionalType&, const T&>::Value && TAllowUnwrapping<T>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, const T&> && CAssignable<OptionalType&, const T&> && TAllowUnwrapping<T>::Value
constexpr TOptional& operator=(const TOptional<T>& InValue)
{
Reference = InValue.Reference;
return *this;
}
template <typename T = OptionalType> requires TIsConstructible<OptionalType, T&&>::Value && TIsAssignable<OptionalType&, T&&>::Value
template <typename T = OptionalType> requires CConstructible<OptionalType, T&&> && CAssignable<OptionalType&, T&&>
constexpr TOptional& operator=(T&& InValue)
{
Reference = InValue;
return *this;
}
template <typename... ArgTypes> requires TIsConstructible<OptionalType, ArgTypes...>::Value
template <typename... ArgTypes> requires CConstructible<OptionalType, ArgTypes...>
constexpr OptionalType& Emplace(ArgTypes&&... Args)
{
Reference = TReferenceWrapper<ReferencedType>(Forward<ArgTypes>(Args)...);
@ -221,7 +221,7 @@ public:
private:
TReferenceWrapper<ReferencedType> Reference;
template <typename T> requires TIsDestructible<T>::Value friend struct TOptional;
template <typename T> requires CDestructible<T> friend struct TOptional;
};

View File

@ -236,23 +236,23 @@ public:
TTuple() = default;
template <typename... ArgTypes> requires (ElementSize > 0) && (sizeof...(ArgTypes) == ElementSize)
&& (true && ... && TIsConstructible<Types, ArgTypes&&>::Value)
&& (true && ... && CConstructible<Types, ArgTypes&&>)
&& (true && ... && TIsConvertible<ArgTypes&&, Types>::Value)
constexpr TTuple(ArgTypes&&... Args)
: Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward<ArgTypes>(Args)...)
{ }
template <typename... ArgTypes> requires (ElementSize > 0) && (sizeof...(ArgTypes) == ElementSize)
&& (true && ... && TIsConstructible<Types, ArgTypes&&>::Value)
&& (true && ... && CConstructible<Types, ArgTypes&&>)
&& (!(true && ... && TIsConvertible<ArgTypes&&, Types>::Value))
constexpr explicit TTuple(ArgTypes&&... Args)
: Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward<ArgTypes>(Args)...)
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == ElementSize)
&& (true && ... && TIsConstructible<Types, const OtherTypes&>::Value)
&& (true && ... && CConstructible<Types, const OtherTypes&>)
&& ((ElementSize != 1) || !(TIsConvertible<const TTuple<OtherTypes...>&, typename TElementType<0>::Type>::Value
|| TIsConstructible<typename TElementType<0>::Type, const TTuple<OtherTypes...>&>::Value
|| CConstructible<typename TElementType<0>::Type, const TTuple<OtherTypes...>&>
|| TIsSame<typename TElementType<0>::Type, typename TTuple<OtherTypes...>::template TElementType<0>::Type>::Value))
&& (true && ... && TIsConvertible<OtherTypes&&, Types>::Value)
constexpr TTuple(const TTuple<OtherTypes...>& InValue)
@ -260,9 +260,9 @@ public:
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == ElementSize)
&& (true && ... && TIsConstructible<Types, const OtherTypes&>::Value)
&& (true && ... && CConstructible<Types, const OtherTypes&>)
&& ((ElementSize != 1) || !(TIsConvertible<const TTuple<OtherTypes...>&, typename TElementType<0>::Type>::Value
|| TIsConstructible<typename TElementType<0>::Type, const TTuple<OtherTypes...>&>::Value
|| CConstructible<typename TElementType<0>::Type, const TTuple<OtherTypes...>&>
|| TIsSame<typename TElementType<0>::Type, typename TTuple<OtherTypes...>::template TElementType<0>::Type>::Value))
&& (!(true && ... && TIsConvertible<OtherTypes&&, Types>::Value))
constexpr explicit TTuple(const TTuple<OtherTypes...>& InValue)
@ -270,9 +270,9 @@ public:
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == ElementSize)
&& (true && ... && TIsConstructible<Types, OtherTypes&&>::Value)
&& (true && ... && CConstructible<Types, OtherTypes&&>)
&& ((ElementSize != 1) || !(TIsConvertible<TTuple<OtherTypes...>&&, typename TElementType<0>::Type>::Value
|| TIsConstructible<typename TElementType<0>::Type, TTuple<OtherTypes...>&&>::Value
|| CConstructible<typename TElementType<0>::Type, TTuple<OtherTypes...>&&>
|| TIsSame<typename TElementType<0>::Type, typename TTuple<OtherTypes...>::template TElementType<0>::Type>::Value))
&& (true && ... && TIsConvertible<OtherTypes&&, Types>::Value)
constexpr TTuple(TTuple<OtherTypes...>&& InValue)
@ -280,9 +280,9 @@ public:
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == ElementSize)
&& (true && ... && TIsConstructible<Types, OtherTypes&&>::Value)
&& (true && ... && CConstructible<Types, OtherTypes&&>)
&& ((ElementSize != 1) || !(TIsConvertible<TTuple<OtherTypes...>&&, typename TElementType<0>::Type>::Value
|| TIsConstructible<typename TElementType<0>::Type, TTuple<OtherTypes...>&&>::Value
|| CConstructible<typename TElementType<0>::Type, TTuple<OtherTypes...>&&>
|| TIsSame<typename TElementType<0>::Type, typename TTuple<OtherTypes...>::template TElementType<0>::Type>::Value))
&& (!(true && ... && TIsConvertible<OtherTypes&&, Types>::Value))
constexpr explicit TTuple(TTuple<OtherTypes...>&& InValue)
@ -293,7 +293,7 @@ public:
TTuple(TTuple&&) = default;
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == ElementSize)
&& (true && ... && TIsAssignable<Types&, const OtherTypes&>::Value)
&& (true && ... && CAssignable<Types&, const OtherTypes&>)
constexpr TTuple& operator=(const TTuple<OtherTypes...>& InValue)
{
Helper::Assign(*this, InValue);
@ -301,7 +301,7 @@ public:
}
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == ElementSize)
&& (true && ... && TIsAssignable<Types&, OtherTypes&&>::Value)
&& (true && ... && CAssignable<Types&, OtherTypes&&>)
constexpr TTuple& operator=(TTuple<OtherTypes...>&& InValue)
{
Helper::Assign(*this, MoveTemp(InValue));
@ -365,21 +365,21 @@ public:
template <typename F> requires (true && ... && (TIsInvocable<F, Types>::Value && !TIsSame<void, typename TInvokeResult<F, Types>::Type>::Value)) constexpr auto Transform(F&& Func) volatile&& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (TIsInvocable<F, Types>::Value && !TIsSame<void, typename TInvokeResult<F, Types>::Type>::Value)) constexpr auto Transform(F&& Func) const volatile&& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() & { return Helper::template Construct<T>(static_cast< TTuple& >(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() const & { return Helper::template Construct<T>(static_cast<const TTuple& >(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() volatile& { return Helper::template Construct<T>(static_cast< volatile TTuple& >(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() const volatile& { return Helper::template Construct<T>(static_cast<const volatile TTuple& >(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() && { return Helper::template Construct<T>(static_cast< TTuple&&>(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() const && { return Helper::template Construct<T>(static_cast<const TTuple&&>(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() volatile&& { return Helper::template Construct<T>(static_cast< volatile TTuple&&>(*this)); }
template <typename T> requires TIsConstructible<T, Types...>::Value constexpr T Construct() const volatile&& { return Helper::template Construct<T>(static_cast<const volatile TTuple&&>(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() & { return Helper::template Construct<T>(static_cast< TTuple& >(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() const & { return Helper::template Construct<T>(static_cast<const TTuple& >(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() volatile& { return Helper::template Construct<T>(static_cast< volatile TTuple& >(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() const volatile& { return Helper::template Construct<T>(static_cast<const volatile TTuple& >(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() && { return Helper::template Construct<T>(static_cast< TTuple&&>(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() const && { return Helper::template Construct<T>(static_cast<const TTuple&&>(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() volatile&& { return Helper::template Construct<T>(static_cast< volatile TTuple&&>(*this)); }
template <typename T> requires CConstructible<T, Types...> constexpr T Construct() const volatile&& { return Helper::template Construct<T>(static_cast<const volatile TTuple&&>(*this)); }
constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Types>)
{
return [this]<size_t... Indices>(TIndexSequence<Indices...>) -> size_t { return HashCombine(NAMESPACE_REDCRAFT::GetTypeHash(GetValue<Indices>())...); } (TMakeIndexSequence<ElementSize>());
}
constexpr void Swap(TTuple& InValue) requires (true && ... && (TIsMoveConstructible<Types>::Value&& TIsSwappable<Types>::Value))
constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible<Types>&& TIsSwappable<Types>::Value))
{
[&A = *this, &B = InValue]<size_t... Indices>(TIndexSequence<Indices...>) { ((NAMESPACE_REDCRAFT::Swap(A.template GetValue<Indices>(), B.template GetValue<Indices>())), ...); } (TMakeIndexSequence<ElementSize>());
}

View File

@ -62,7 +62,7 @@ constexpr T&& Forward(typename TRemoveReference<T>::Type&& Obj)
}
template <typename T> requires requires(T& A, T& B) { A.Swap(B); }
|| (TIsMoveConstructible<T>::Value && TIsMoveAssignable<T>::Value)
|| (CMoveConstructible<T> && CMoveAssignable<T>)
constexpr void Swap(T& A, T& B)
{
if constexpr (requires(T& A, T& B) { A.Swap(B); })
@ -77,7 +77,7 @@ constexpr void Swap(T& A, T& B)
}
}
template <typename T, typename U = T> requires TIsMoveConstructible<T>::Value && TIsAssignable<T&, U>::Value
template <typename T, typename U = T> requires CMoveConstructible<T> && CAssignable<T&, U>
constexpr T Exchange(T& A, U&& B)
{
T Temp = MoveTemp(A);

View File

@ -49,7 +49,7 @@ struct TVariantSelectedType;
template <typename T, typename U, typename... Types>
struct TVariantSelectedType<T, U, Types...>
{
using TypeAlternativeA = typename TConditional<TIsConstructible<U, T&&>::Value, U, void>::Type;
using TypeAlternativeA = typename TConditional<CConstructible<U, T&&>, U, void>::Type;
using TypeAlternativeB = typename TVariantSelectedType<T, Types...>::Type;
using Type = typename TConditional<TIsSame<typename TRemoveCVRef<TypeAlternativeA>::Type, void>::Value, TypeAlternativeB,
@ -78,7 +78,7 @@ struct TVariantSelectedType<T>
NAMESPACE_PRIVATE_END
template <typename... Types> requires (true && ... && TIsDestructible<Types>::Value) && (sizeof...(Types) < 0xFF)
template <typename... Types> requires (true && ... && CDestructible<Types>) && (sizeof...(Types) < 0xFF)
struct TVariant
{
static constexpr size_t AlternativeSize = sizeof...(Types);
@ -90,20 +90,20 @@ struct TVariant
constexpr TVariant(FInvalid) : TVariant() { };
constexpr TVariant(const TVariant& InValue) requires (true && ... && TIsCopyConstructible<Types>::Value)
constexpr TVariant(const TVariant& InValue) requires (true && ... && CCopyConstructible<Types>)
: TypeIndex(static_cast<uint8>(InValue.GetIndex()))
{
if (IsValid()) CopyConstructImpl[InValue.GetIndex()](&Value, &InValue.Value);
}
constexpr TVariant(TVariant&& InValue) requires (true && ... && TIsMoveConstructible<Types>::Value)
constexpr TVariant(TVariant&& InValue) requires (true && ... && CMoveConstructible<Types>)
: TypeIndex(static_cast<uint8>(InValue.GetIndex()))
{
if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value);
}
template <size_t I, typename... ArgTypes> requires (I < AlternativeSize)
&& TIsConstructible<typename TAlternativeType<I>::Type, ArgTypes...>::Value
&& CConstructible<typename TAlternativeType<I>::Type, ArgTypes...>
constexpr explicit TVariant(TInPlaceIndex<I>, ArgTypes&&... Args)
: TypeIndex(I)
{
@ -112,7 +112,7 @@ struct TVariant
}
template <typename T, typename... ArgTypes> requires (TAlternativeIndex<T>::Value != INDEX_NONE)
&& TIsConstructible<typename TAlternativeType<TAlternativeIndex<T>::Value>::Type, ArgTypes...>::Value
&& CConstructible<typename TAlternativeType<TAlternativeIndex<T>::Value>::Type, ArgTypes...>
constexpr explicit TVariant(TInPlaceType<T>, ArgTypes&&... Args)
: TVariant(InPlaceIndex<TAlternativeIndex<T>::Value>, Forward<ArgTypes>(Args)...)
{ }
@ -125,10 +125,10 @@ struct TVariant
constexpr ~TVariant()
{
if constexpr (!(true && ... && TIsTriviallyDestructible<Types>::Value)) Reset();
if constexpr (!(true && ... && CTriviallyDestructible<Types>)) Reset();
}
constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (TIsCopyConstructible<Types>::Value && TIsCopyAssignable<Types>::Value))
constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CCopyConstructible<Types> && CCopyAssignable<Types>))
{
if (&InValue == this) return *this;
@ -149,7 +149,7 @@ struct TVariant
return *this;
}
constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (TIsMoveConstructible<Types>::Value && TIsMoveAssignable<Types>::Value))
constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CMoveConstructible<Types> && CMoveAssignable<Types>))
{
if (&InValue == this) return *this;
@ -187,7 +187,7 @@ struct TVariant
}
template <size_t I, typename... ArgTypes> requires (I < AlternativeSize)
&& TIsConstructible<typename TAlternativeType<I>::Type, ArgTypes...>::Value
&& CConstructible<typename TAlternativeType<I>::Type, ArgTypes...>
constexpr typename TAlternativeType<I>::Type& Emplace(ArgTypes&&... Args)
{
Reset();
@ -200,7 +200,7 @@ struct TVariant
}
template <typename T, typename... ArgTypes> requires (TAlternativeIndex<T>::Value != INDEX_NONE)
&& TIsConstructible<typename TAlternativeType<TAlternativeIndex<T>::Value>::Type, ArgTypes...>::Value
&& CConstructible<typename TAlternativeType<TAlternativeIndex<T>::Value>::Type, ArgTypes...>
constexpr T& Emplace(ArgTypes&&... Args)
{
return Emplace<TAlternativeIndex<T>::Value>(Forward<ArgTypes>(Args)...);
@ -299,7 +299,7 @@ struct TVariant
{
if (GetIndex() == INDEX_NONE) return;
if constexpr (!(true && ... && TIsTriviallyDestructible<Types>::Value))
if constexpr (!(true && ... && CTriviallyDestructible<Types>))
{
DestroyImpl[GetIndex()](&Value);
}
@ -319,7 +319,7 @@ struct TVariant
return HashCombine(GetTypeHash(GetIndex()), HashImpl[GetIndex()](&Value));
}
constexpr void Swap(TVariant& InValue) requires (true && ... && (TIsMoveConstructible<Types>::Value && TIsSwappable<Types>::Value))
constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible<Types> && TIsSwappable<Types>::Value))
{
if (!IsValid() && !InValue.IsValid()) return;

View File

@ -14,7 +14,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
// Assume that all operands of bitwise operations have the same size
// This type traits is allowed to be specialised.
template <typename T> struct TIsZeroConstructible : TBoolConstant<TIsDefaultConstructible<T>::Value && (CEnum<T> || CArithmetic<T> || CPointer<T>)> { };
template <typename T> struct TIsZeroConstructible : TBoolConstant<CDefaultConstructible<T> && (CEnum<T> || CArithmetic<T> || CPointer<T>)> { };
// This type traits is allowed to be specialised.
template <typename T, typename U> struct TIsBitwiseConstructible;
@ -37,7 +37,7 @@ template <typename T, typename U> struct TIsBitwiseConstructible<const volatile
template <typename T, typename U> struct TIsBitwiseConstructible<T*, U*> : TIsConvertible<U*, T*> { };
template <typename T, typename U> struct TIsBitwiseConstructible : TBoolConstant<TIsSame<T, U>::Value ? TIsTriviallyCopyConstructible<T>::Value : false> { };
template <typename T, typename U> struct TIsBitwiseConstructible : TBoolConstant<TIsSame<T, U>::Value ? CTriviallyCopyConstructible<T> : false> { };
template <> struct TIsBitwiseConstructible<uint8, int8> : FTrue { };
template <> struct TIsBitwiseConstructible< int8, uint8> : FTrue { };
@ -69,7 +69,7 @@ template <typename T, typename U> struct TIsBitwiseRelocatable<const volatile T,
template <typename T> struct TIsBitwiseRelocatable<T, T> : TBoolConstant<CObject<T>> { };
template <typename T, typename U> struct TIsBitwiseRelocatable : TBoolConstant<TIsBitwiseConstructible<T, U>::Value && TIsTriviallyDestructible<U>::Value> { };
template <typename T, typename U> struct TIsBitwiseRelocatable : TBoolConstant<TIsBitwiseConstructible<T, U>::Value && CTriviallyDestructible<U>> { };
// This type traits is allowed to be specialised.
template <typename T> struct TIsBitwiseComparable : TBoolConstant<CEnum<T> || CArithmetic<T> || CPointer<T>> { };

View File

@ -12,44 +12,43 @@ NAMESPACE_MODULE_BEGIN(Utility)
NAMESPACE_PRIVATE_BEGIN
// Cpp17Destructible requirements
template <typename T>
struct TIsCpp17Destructible : TBoolConstant<NAMESPACE_STD::is_object_v<T> && !NAMESPACE_STD::is_array_v<T> && NAMESPACE_STD::is_destructible_v<T>> { };
template <typename T> concept CCpp17Destructible = NAMESPACE_STD::is_object_v<T> && !NAMESPACE_STD::is_array_v<T> && NAMESPACE_STD::is_destructible_v<T>;
NAMESPACE_PRIVATE_END
template <typename T> struct TIsDefaultConstructible : TBoolConstant<NAMESPACE_STD::is_default_constructible_v<T>> { };
template <typename T> struct TIsCopyConstructible : TBoolConstant<NAMESPACE_STD::is_copy_constructible_v<T>> { };
template <typename T> struct TIsMoveConstructible : TBoolConstant<NAMESPACE_STD::is_move_constructible_v<T>> { };
template <typename T> struct TIsCopyAssignable : TBoolConstant<NAMESPACE_STD::is_copy_assignable_v<T>> { };
template <typename T> struct TIsMoveAssignable : TBoolConstant<NAMESPACE_STD::is_move_assignable_v<T>> { };
template <typename T> struct TIsDestructible : NAMESPACE_PRIVATE::TIsCpp17Destructible<T> { }; // Use Cpp17Destructible requirements instead of std::is_destructible
template <typename T> concept CDefaultConstructible = NAMESPACE_STD::is_default_constructible_v<T>;
template <typename T> concept CCopyConstructible = NAMESPACE_STD::is_copy_constructible_v<T>;
template <typename T> concept CMoveConstructible = NAMESPACE_STD::is_move_constructible_v<T>;
template <typename T> concept CCopyAssignable = NAMESPACE_STD::is_copy_assignable_v<T>;
template <typename T> concept CMoveAssignable = NAMESPACE_STD::is_move_assignable_v<T>;
template <typename T> concept CDestructible = NAMESPACE_PRIVATE::CCpp17Destructible<T>; // Use Cpp17Destructible requirements instead of std::is_destructible
template <typename T> struct TIsTriviallyDefaultConstructible : TBoolConstant<TIsDefaultConstructible<T>::Value && NAMESPACE_STD::is_trivially_default_constructible_v<T>> { };
template <typename T> struct TIsTriviallyCopyConstructible : TBoolConstant<TIsCopyConstructible<T>::Value && NAMESPACE_STD::is_trivially_copy_constructible_v<T>> { };
template <typename T> struct TIsTriviallyMoveConstructible : TBoolConstant<TIsMoveConstructible<T>::Value && NAMESPACE_STD::is_trivially_move_constructible_v<T>> { };
template <typename T> struct TIsTriviallyCopyAssignable : TBoolConstant<TIsCopyAssignable<T>::Value && NAMESPACE_STD::is_trivially_copy_assignable_v<T>> { };
template <typename T> struct TIsTriviallyMoveAssignable : TBoolConstant<TIsMoveAssignable<T>::Value && NAMESPACE_STD::is_trivially_move_assignable_v<T>> { };
template <typename T> struct TIsTriviallyDestructible : TBoolConstant<TIsDestructible<T>::Value && NAMESPACE_STD::is_trivially_destructible_v<T>> { };
template <typename T> struct THasVirtualDestructor : TBoolConstant<TIsDestructible<T>::Value && NAMESPACE_STD::has_virtual_destructor_v<T>> { };
template <typename T> concept CTriviallyDefaultConstructible = CDefaultConstructible<T> && NAMESPACE_STD::is_trivially_default_constructible_v<T>;
template <typename T> concept CTriviallyCopyConstructible = CCopyConstructible<T> && NAMESPACE_STD::is_trivially_copy_constructible_v<T>;
template <typename T> concept CTriviallyMoveConstructible = CMoveConstructible<T> && NAMESPACE_STD::is_trivially_move_constructible_v<T>;
template <typename T> concept CTriviallyCopyAssignable = CCopyAssignable<T> && NAMESPACE_STD::is_trivially_copy_assignable_v<T>;
template <typename T> concept CTriviallyMoveAssignable = CMoveAssignable<T> && NAMESPACE_STD::is_trivially_move_assignable_v<T>;
template <typename T> concept CTriviallyDestructible = CDestructible<T> && NAMESPACE_STD::is_trivially_destructible_v<T>;
template <typename T> concept CVirtualDestructible = CDestructible<T> && NAMESPACE_STD::has_virtual_destructor_v<T>;
//template <typename T> struct TIsNothrowDefaultConstructible;
//template <typename T> struct TIsNothrowCopyConstructible;
//template <typename T> struct TIsNothrowMoveConstructible;
//template <typename T> struct TIsNothrowCopyAssignable;
//template <typename T> struct TIsNothrowMoveAssignable;
//template <typename T> struct TIsNothrowDestructible;
//template <typename T> concept CNothrowDefaultConstructible;
//template <typename T> concept CNothrowCopyConstructible;
//template <typename T> concept CNothrowMoveConstructible;
//template <typename T> concept CNothrowCopyAssignable;
//template <typename T> concept CNothrowMoveAssignable;
//template <typename T> concept CNothrowDestructible;
template <typename T, typename U> struct TIsAssignable : TBoolConstant<NAMESPACE_STD::is_assignable_v<T, U>> { };
template <typename T, typename U> concept CAssignable = NAMESPACE_STD::is_assignable_v<T, U>;
template <typename T, typename U> struct TIsTriviallyAssignable : TBoolConstant<TIsAssignable<T, U>::Value && NAMESPACE_STD::is_trivially_assignable_v<T, U>> { };
template <typename T, typename U> concept CTriviallyAssignable = CAssignable<T, U> && NAMESPACE_STD::is_trivially_assignable_v<T, U>;
//template <typename T, typename U> struct TIsNothrowAssignable;
//template <typename T, typename U> concept CNothrowAssignable;
template <typename T, typename... Args> struct TIsConstructible : TBoolConstant<NAMESPACE_STD::is_constructible_v<T, Args...>> { };
template <typename T, typename... Args> concept CConstructible = NAMESPACE_STD::is_constructible_v<T, Args...>;
template <typename T, typename... Args> struct TIsTriviallyConstructible : TBoolConstant<TIsConstructible<T, Args...>::Value && NAMESPACE_STD::is_trivially_constructible_v<T, Args...>> { };
template <typename T, typename... Args> concept CTriviallyConstructible = CConstructible<T, Args...> && NAMESPACE_STD::is_trivially_constructible_v<T, Args...>;
//template <typename T, typename... Args> struct TIsNothrowConstructible;
//template <typename T, typename... Args> concept CNothrowConstructible;
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)