style(*): replaces Types... in the template parameters with Ts...

This commit is contained in:
_Redstone_c_ 2022-11-16 19:13:37 +08:00
parent f347132725
commit d37eee0d23
12 changed files with 392 additions and 392 deletions

View File

@ -24,21 +24,21 @@ template<> struct TCommonComparisonCategoryBasic<2> { using Type = partial_
template<> struct TCommonComparisonCategoryBasic<4> { using Type = weak_ordering; };
template<> struct TCommonComparisonCategoryBasic<6> { using Type = partial_ordering; };
template <typename... Types>
template <typename... Ts>
struct TCommonComparisonCategoryImpl
: TCommonComparisonCategoryBasic <(0u | ... |
(
CSameAs<Types, strong_ordering > ? 0u :
CSameAs<Types, weak_ordering > ? 4u :
CSameAs<Types, partial_ordering> ? 2u : 1u
CSameAs<Ts, strong_ordering > ? 0u :
CSameAs<Ts, weak_ordering > ? 4u :
CSameAs<Ts, partial_ordering> ? 2u : 1u
)
)>
{ };
NAMESPACE_PRIVATE_END
template <typename... Types>
using TCommonComparisonCategory = typename NAMESPACE_PRIVATE::TCommonComparisonCategoryImpl<Types...>::Type;
template <typename... Ts>
using TCommonComparisonCategory = typename NAMESPACE_PRIVATE::TCommonComparisonCategoryImpl<Ts...>::Type;
template <typename T, typename OrderingType>
concept CThreeWayComparesAs = CSameAs<TCommonComparisonCategory<T, OrderingType>, OrderingType>;

View File

@ -131,12 +131,12 @@ public:
}
}
template <typename T, typename... Types> requires CDestructible<TDecay<T>>
&& CConstructibleFrom<TDecay<T>, Types&&...>
FORCEINLINE explicit TAny(TInPlaceType<T>, Types&&... Args)
template <typename T, typename... Ts> requires CDestructible<TDecay<T>>
&& CConstructibleFrom<TDecay<T>, Ts&&...>
FORCEINLINE explicit TAny(TInPlaceType<T>, Ts&&... Args)
{
using SelectedType = TDecay<T>;
EmplaceImpl<SelectedType>(Forward<Types>(Args)...);
EmplaceImpl<SelectedType>(Forward<Ts>(Args)...);
}
template <typename T> requires (!CSameAs<TDecay<T>, TAny>) && (!CTInPlaceType<TDecay<T>>)
@ -270,14 +270,14 @@ public:
return *this;
}
template <typename T, typename... Types> requires CDestructible<TDecay<T>>
&& CConstructibleFrom<TDecay<T>, Types&&...>
FORCEINLINE TDecay<T>& Emplace(Types&&... Args)
template <typename T, typename... Ts> requires CDestructible<TDecay<T>>
&& CConstructibleFrom<TDecay<T>, Ts&&...>
FORCEINLINE TDecay<T>& Emplace(Ts&&... Args)
{
ResetImpl();
using SelectedType = TDecay<T>;
EmplaceImpl<SelectedType>(Forward<Types>(Args)...);
EmplaceImpl<SelectedType>(Forward<Ts>(Args)...);
return GetValue<SelectedType>();
}
@ -400,11 +400,11 @@ private:
, TypeSize ( sizeof(T))
, TypeAlignment (alignof(T))
, CopyConstructImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast<T*>(A), reinterpret_cast<const T*>(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(Types).name()); })
, MoveConstructImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast<T*>(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(Types).name()); })
, CopyAssignImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast<T*>(A), reinterpret_cast<const T*>(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(Types).name()); })
, MoveAssignImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast<T*>(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(Types).name()); })
, DestroyImpl ([](void* A ) { if constexpr (requires(T* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast<T*>(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(Types).name()); })
, CopyConstructImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast<T*>(A), reinterpret_cast<const T*>(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(T).name()); })
, MoveConstructImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast<T*>(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(T).name()); })
, CopyAssignImpl ([](void* A, const void* B) { if constexpr (requires(T* A, const T* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast<T*>(A), reinterpret_cast<const T*>(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(T).name()); })
, MoveAssignImpl ([](void* A, void* B) { if constexpr (requires(T* A, T* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast<T*>(A), reinterpret_cast< T*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(T).name()); })
, DestroyImpl ([](void* A ) { if constexpr (requires(T* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast<T*>(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(T).name()); })
, EqualityCompareImpl ([](const void* A, const void* B) -> bool { if constexpr (CEqualityComparable<T> ) return (*reinterpret_cast<const T*>(A) == *reinterpret_cast<const T*>(B)); else checkf(false, TEXT("The type '%s' is not equality comparable."), typeid(T).name()); return false; })
, SynthThreeWayCompareImpl ([](const void* A, const void* B) -> partial_ordering { if constexpr (CSynthThreeWayComparable<T>) return NAMESPACE_REDCRAFT::SynthThreeWayCompare (*reinterpret_cast<const T*>(A), *reinterpret_cast<const T*>(B)); else checkf(false, TEXT("The type '%s' is not synth three-way comparable."), typeid(T).name()); return partial_ordering::unordered; })
@ -420,8 +420,8 @@ private:
constexpr void* GetAllocation() { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? Storage.InlineAllocation() : Storage.HeapAllocation(); }
constexpr const void* GetAllocation() const { return GetRepresentation() == ERepresentation::Trivial || GetRepresentation() == ERepresentation::Small ? Storage.InlineAllocation() : Storage.HeapAllocation(); }
template <typename SelectedType, typename... Types>
FORCEINLINE void EmplaceImpl(Types&&... Args)
template <typename SelectedType, typename... Ts>
FORCEINLINE void EmplaceImpl(Ts&&... Args)
{
static constexpr const FTypeInfoImpl SelectedTypeInfo(InPlaceType<SelectedType>);
Storage.TypeInfo() = reinterpret_cast<uintptr>(&SelectedTypeInfo);
@ -431,17 +431,17 @@ private:
if constexpr (bIsTriviallyStorable)
{
new(Storage.InlineAllocation()) SelectedType(Forward<Types>(Args)...);
new(Storage.InlineAllocation()) SelectedType(Forward<Ts>(Args)...);
Storage.TypeInfo() |= static_cast<uintptr>(ERepresentation::Trivial);
}
else if constexpr (bIsInlineStorable)
{
new(Storage.InlineAllocation()) SelectedType(Forward<Types>(Args)...);
new(Storage.InlineAllocation()) SelectedType(Forward<Ts>(Args)...);
Storage.TypeInfo() |= static_cast<uintptr>(ERepresentation::Small);
}
else
{
Storage.HeapAllocation() = new SelectedType(Forward<Types>(Args)...);
Storage.HeapAllocation() = new SelectedType(Forward<Ts>(Args)...);
Storage.TypeInfo() |= static_cast<uintptr>(ERepresentation::Big);
}
}

View File

@ -56,39 +56,39 @@ constexpr bool FunctionIsBound(const T& Func)
template <typename Signature, typename F> struct TIsInvocableSignature : FFalse { };
template <typename Ret, typename... Types, typename F>
struct TIsInvocableSignature<Ret(Types...), F>
: TBoolConstant<CInvocableResult<Ret, F, Types...> && CInvocableResult<Ret, F&, Types...>>
template <typename Ret, typename... Ts, typename F>
struct TIsInvocableSignature<Ret(Ts...), F>
: TBoolConstant<CInvocableResult<Ret, F, Ts...> && CInvocableResult<Ret, F&, Ts...>>
{ };
template <typename Ret, typename... Types, typename F> struct TIsInvocableSignature<Ret(Types...) & , F> : TBoolConstant<CInvocableResult<Ret, F&, Types...>> { };
template <typename Ret, typename... Types, typename F> struct TIsInvocableSignature<Ret(Types...) &&, F> : TBoolConstant<CInvocableResult<Ret, F , Types...>> { };
template <typename Ret, typename... Ts, typename F> struct TIsInvocableSignature<Ret(Ts...) & , F> : TBoolConstant<CInvocableResult<Ret, F&, Ts...>> { };
template <typename Ret, typename... Ts, typename F> struct TIsInvocableSignature<Ret(Ts...) &&, F> : TBoolConstant<CInvocableResult<Ret, F , Ts...>> { };
template <typename Ret, typename... Types, typename F>
struct TIsInvocableSignature<Ret(Types...) const, F>
: TBoolConstant<CInvocableResult<Ret, const F, Types...> && CInvocableResult<Ret, const F&, Types...>>
template <typename Ret, typename... Ts, typename F>
struct TIsInvocableSignature<Ret(Ts...) const, F>
: TBoolConstant<CInvocableResult<Ret, const F, Ts...> && CInvocableResult<Ret, const F&, Ts...>>
{ };
template <typename Ret, typename... Types, typename F> struct TIsInvocableSignature<Ret(Types...) const& , F> : TBoolConstant<CInvocableResult<Ret, const F&, Types...>> { };
template <typename Ret, typename... Types, typename F> struct TIsInvocableSignature<Ret(Types...) const&&, F> : TBoolConstant<CInvocableResult<Ret, const F , Types...>> { };
template <typename Ret, typename... Ts, typename F> struct TIsInvocableSignature<Ret(Ts...) const& , F> : TBoolConstant<CInvocableResult<Ret, const F&, Ts...>> { };
template <typename Ret, typename... Ts, typename F> struct TIsInvocableSignature<Ret(Ts...) const&&, F> : TBoolConstant<CInvocableResult<Ret, const F , Ts...>> { };
template <typename F> struct TFunctionInfo;
template <typename Ret, typename... Types> struct TFunctionInfo<Ret(Types...) > { using Fn = Ret(Types...); using CVRef = int; };
template <typename Ret, typename... Types> struct TFunctionInfo<Ret(Types...) & > { using Fn = Ret(Types...); using CVRef = int&; };
template <typename Ret, typename... Types> struct TFunctionInfo<Ret(Types...) && > { using Fn = Ret(Types...); using CVRef = int&&; };
template <typename Ret, typename... Types> struct TFunctionInfo<Ret(Types...) const > { using Fn = Ret(Types...); using CVRef = const int; };
template <typename Ret, typename... Types> struct TFunctionInfo<Ret(Types...) const& > { using Fn = Ret(Types...); using CVRef = const int&; };
template <typename Ret, typename... Types> struct TFunctionInfo<Ret(Types...) const&&> { using Fn = Ret(Types...); using CVRef = const int&&; };
template <typename Ret, typename... Ts> struct TFunctionInfo<Ret(Ts...) > { using Fn = Ret(Ts...); using CVRef = int; };
template <typename Ret, typename... Ts> struct TFunctionInfo<Ret(Ts...) & > { using Fn = Ret(Ts...); using CVRef = int&; };
template <typename Ret, typename... Ts> struct TFunctionInfo<Ret(Ts...) && > { using Fn = Ret(Ts...); using CVRef = int&&; };
template <typename Ret, typename... Ts> struct TFunctionInfo<Ret(Ts...) const > { using Fn = Ret(Ts...); using CVRef = const int; };
template <typename Ret, typename... Ts> struct TFunctionInfo<Ret(Ts...) const& > { using Fn = Ret(Ts...); using CVRef = const int&; };
template <typename Ret, typename... Ts> struct TFunctionInfo<Ret(Ts...) const&&> { using Fn = Ret(Ts...); using CVRef = const int&&; };
template <typename F, typename CVRef, bool bIsRef> class TFunctionImpl;
template <typename Ret, typename... Types, typename CVRef, bool bIsRef>
class TFunctionImpl<Ret(Types...), CVRef, bIsRef>
template <typename Ret, typename... Ts, typename CVRef, bool bIsRef>
class TFunctionImpl<Ret(Ts...), CVRef, bIsRef>
{
public:
using ResultType = Ret;
using ArgumentType = TTuple<Types...>;
using ArgumentType = TTuple<Ts...>;
TFunctionImpl() = default;
TFunctionImpl(const TFunctionImpl&) = default;
@ -97,12 +97,12 @@ public:
TFunctionImpl& operator=(TFunctionImpl&&) = default;
~TFunctionImpl() = default;
FORCEINLINE ResultType operator()(Types... Args) requires (CSameAs<CVRef, int >) { return CallImpl(Forward<Types>(Args)...); }
FORCEINLINE ResultType operator()(Types... Args) & requires (CSameAs<CVRef, int& >) { return CallImpl(Forward<Types>(Args)...); }
FORCEINLINE ResultType operator()(Types... Args) && requires (CSameAs<CVRef, int&&>) { return CallImpl(Forward<Types>(Args)...); }
FORCEINLINE ResultType operator()(Types... Args) const requires (CSameAs<CVRef, const int >) { return CallImpl(Forward<Types>(Args)...); }
FORCEINLINE ResultType operator()(Types... Args) const& requires (CSameAs<CVRef, const int& >) { return CallImpl(Forward<Types>(Args)...); }
FORCEINLINE ResultType operator()(Types... Args) const&& requires (CSameAs<CVRef, const int&&>) { return CallImpl(Forward<Types>(Args)...); }
FORCEINLINE ResultType operator()(Ts... Args) requires (CSameAs<CVRef, int >) { return CallImpl(Forward<Ts>(Args)...); }
FORCEINLINE ResultType operator()(Ts... Args) & requires (CSameAs<CVRef, int& >) { return CallImpl(Forward<Ts>(Args)...); }
FORCEINLINE ResultType operator()(Ts... Args) && requires (CSameAs<CVRef, int&&>) { return CallImpl(Forward<Ts>(Args)...); }
FORCEINLINE ResultType operator()(Ts... Args) const requires (CSameAs<CVRef, const int >) { return CallImpl(Forward<Ts>(Args)...); }
FORCEINLINE ResultType operator()(Ts... Args) const& requires (CSameAs<CVRef, const int& >) { return CallImpl(Forward<Ts>(Args)...); }
FORCEINLINE ResultType operator()(Ts... Args) const&& requires (CSameAs<CVRef, const int&&>) { return CallImpl(Forward<Ts>(Args)...); }
constexpr bool IsValid() const { return GetCallableImpl() != nullptr; }
constexpr explicit operator bool() const { return GetCallableImpl() != nullptr; }
@ -140,7 +140,7 @@ public:
private:
using StoragePtrType = TCopyConst<CVRef, void>*;
using CallableType = ResultType(*)(StoragePtrType, Types&&...);
using CallableType = ResultType(*)(StoragePtrType, Ts&&...);
struct FunctionRefStorage
{
@ -193,18 +193,18 @@ private:
else return Storage.GetCustomStorage().Callable;
}
FORCEINLINE ResultType CallImpl(Types&&... Args)
FORCEINLINE ResultType CallImpl(Ts&&... Args)
{
checkf(IsValid(), TEXT("Attempting to call an unbound TFunction!"));
if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward<Types>(Args)...);
else return GetCallableImpl()(&Storage, Forward<Types>(Args)...);
if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward<Ts>(Args)...);
else return GetCallableImpl()(&Storage, Forward<Ts>(Args)...);
}
FORCEINLINE ResultType CallImpl(Types&&... Args) const
FORCEINLINE ResultType CallImpl(Ts&&... Args) const
{
checkf(IsValid(), TEXT("Attempting to call an unbound TFunction!"));
if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward<Types>(Args)...);
else return GetCallableImpl()(&Storage, Forward<Types>(Args)...);
if constexpr (bIsRef) return GetCallableImpl()(Storage.Ptr, Forward<Ts>(Args)...);
else return GetCallableImpl()(&Storage, Forward<Ts>(Args)...);
}
protected: // These functions should not be used by user-defined class.
@ -217,7 +217,7 @@ protected: // These functions should not be used by user-defined class.
if constexpr (bIsRef) Storage.Ptr = (AddressOf(Args), ...);
else Storage.template Emplace<DecayedType>(Forward<ArgTypes>(Args)...);
GetCallableImpl() = [](StoragePtrType Storage, Types&&... Args) -> ResultType
GetCallableImpl() = [](StoragePtrType Storage, Ts&&... Args) -> ResultType
{
using InvokeType = TConditional<
CReference<CVRef>,
@ -231,7 +231,7 @@ protected: // These functions should not be used by user-defined class.
else return static_cast<InvokeType>(*reinterpret_cast<FuncType*>(Storage));
};
return InvokeResult<ResultType>(GetFunc(), Forward<Types>(Args)...);
return InvokeResult<ResultType>(GetFunc(), Forward<Ts>(Args)...);
};
}
@ -508,32 +508,32 @@ struct TNotFunction
template <typename InF>
constexpr TNotFunction(InF&& InFunc) : Storage(Forward<InF>(InFunc)) { }
template <typename... Types> requires CInvocable<F&, Types&&...>
constexpr auto operator()(Types&&... Args) &
-> decltype(!Invoke(Storage, Forward<Types>(Args)...))
template <typename... Ts> requires CInvocable<F&, Ts&&...>
constexpr auto operator()(Ts&&... Args) &
-> decltype(!Invoke(Storage, Forward<Ts>(Args)...))
{
return !Invoke(Storage, Forward<Types>(Args)...);
return !Invoke(Storage, Forward<Ts>(Args)...);
}
template <typename... Types> requires CInvocable<F&&, Types&&...>
constexpr auto operator()(Types&&... Args) &&
-> decltype(!Invoke(MoveTemp(Storage), Forward<Types>(Args)...))
template <typename... Ts> requires CInvocable<F&&, Ts&&...>
constexpr auto operator()(Ts&&... Args) &&
-> decltype(!Invoke(MoveTemp(Storage), Forward<Ts>(Args)...))
{
return !Invoke(MoveTemp(Storage), Forward<Types>(Args)...);
return !Invoke(MoveTemp(Storage), Forward<Ts>(Args)...);
}
template <typename... Types> requires CInvocable<const F&, Types&&...>
constexpr auto operator()(Types&&... Args) const&
-> decltype(!Invoke(Storage, Forward<Types>(Args)...))
template <typename... Ts> requires CInvocable<const F&, Ts&&...>
constexpr auto operator()(Ts&&... Args) const&
-> decltype(!Invoke(Storage, Forward<Ts>(Args)...))
{
return !Invoke(Storage, Forward<Types>(Args)...);
return !Invoke(Storage, Forward<Ts>(Args)...);
}
template <typename... Types> requires CInvocable<const F&&, Types&&...>
constexpr auto operator()(Types&&... Args) const&&
-> decltype(!Invoke(MoveTemp(Storage), Forward<Types>(Args)...))
template <typename... Ts> requires CInvocable<const F&&, Ts&&...>
constexpr auto operator()(Ts&&... Args) const&&
-> decltype(!Invoke(MoveTemp(Storage), Forward<Ts>(Args)...))
{
return !Invoke(MoveTemp(Storage), Forward<Types>(Args)...);
return !Invoke(MoveTemp(Storage), Forward<Ts>(Args)...);
}
};

View File

@ -12,28 +12,28 @@ NAMESPACE_PRIVATE_BEGIN
struct InvokeFunction
{
template <typename F, typename... Types>
static auto Invoke(F&& Object, Types&&... Args)
-> decltype(Forward<F>(Object)(Forward<Types>(Args)...))
template <typename F, typename... Ts>
static auto Invoke(F&& Object, Ts&&... Args)
-> decltype(Forward<F>(Object)(Forward<Ts>(Args)...))
{
return Forward<F>(Object)(Forward<Types>(Args)...);
return Forward<F>(Object)(Forward<Ts>(Args)...);
}
};
struct InvokeMemberFunction
{
template <typename F, typename ObjectType, typename... Types>
static auto Invoke(F&& Func, ObjectType&& Object, Types&&... Args)
-> decltype((Forward<ObjectType>(Object)->*Func)(Forward<Types>(Args)...))
template <typename F, typename ObjectType, typename... Ts>
static auto Invoke(F&& Func, ObjectType&& Object, Ts&&... Args)
-> decltype((Forward<ObjectType>(Object)->*Func)(Forward<Ts>(Args)...))
{
return (Forward<ObjectType>(Object)->*Func)(Forward<Types>(Args)...);
return (Forward<ObjectType>(Object)->*Func)(Forward<Ts>(Args)...);
}
template <typename F, typename ObjectType, typename... Types>
static auto Invoke(F&& Func, ObjectType&& Object, Types&&... Args)
-> decltype((Forward<ObjectType>(Object).*Func)(Forward<Types>(Args)...))
template <typename F, typename ObjectType, typename... Ts>
static auto Invoke(F&& Func, ObjectType&& Object, Ts&&... Args)
-> decltype((Forward<ObjectType>(Object).*Func)(Forward<Ts>(Args)...))
{
return (Forward<ObjectType>(Object).*Func)(Forward<Types>(Args)...);
return (Forward<ObjectType>(Object).*Func)(Forward<Ts>(Args)...);
}
};
@ -70,29 +70,29 @@ struct InvokeMember<F, T, Decayed, false, true> : InvokeMemberObject { };
template <typename F, typename T, typename Decayed>
struct InvokeMember<F, T, Decayed, false, false> : InvokeFunction { };
template <typename F, typename... Types>
template <typename F, typename... Ts>
struct InvokeImpl;
template <typename F>
struct InvokeImpl<F> : InvokeFunction { };
template <typename F, typename T, typename... Types>
struct InvokeImpl<F, T, Types...> : InvokeMember<F, T> { };
template <typename F, typename T, typename... Ts>
struct InvokeImpl<F, T, Ts...> : InvokeMember<F, T> { };
NAMESPACE_PRIVATE_END
template <typename F, typename... Types> requires CInvocable<F, Types...>
constexpr auto Invoke(F&& Func, Types&&... Args)
-> decltype(NAMESPACE_PRIVATE::InvokeImpl<F, Types...>::Invoke(Forward<F>(Func), Forward<Types>(Args)...))
template <typename F, typename... Ts> requires CInvocable<F, Ts...>
constexpr auto Invoke(F&& Func, Ts&&... Args)
-> decltype(NAMESPACE_PRIVATE::InvokeImpl<F, Ts...>::Invoke(Forward<F>(Func), Forward<Ts>(Args)...))
{
return NAMESPACE_PRIVATE::InvokeImpl<F, Types...>::Invoke(Forward<F>(Func), Forward<Types>(Args)...);
return NAMESPACE_PRIVATE::InvokeImpl<F, Ts...>::Invoke(Forward<F>(Func), Forward<Ts>(Args)...);
}
template <typename R, typename F, typename... Types> requires CInvocableResult<R, F, Types...>
constexpr R InvokeResult(F&& Func, Types&&... Args)
template <typename R, typename F, typename... Ts> requires CInvocableResult<R, F, Ts...>
constexpr R InvokeResult(F&& Func, Ts&&... Args)
{
if constexpr (CVoid<R>) Invoke(Forward<F>(Func), Forward<Types>(Args)...);
else return Invoke(Forward<F>(Func), Forward<Types>(Args)...);
if constexpr (CVoid<R>) Invoke(Forward<F>(Func), Forward<Ts>(Args)...);
else return Invoke(Forward<F>(Func), Forward<Ts>(Args)...);
}
NAMESPACE_MODULE_END(Utility)

View File

@ -40,11 +40,11 @@ public:
constexpr TOptional(FInvalid) : TOptional() { }
template <typename... Types> requires CConstructibleFrom<OptionalType, Types...>
constexpr explicit TOptional(FInPlace, Types&&... Args)
template <typename... Ts> requires CConstructibleFrom<OptionalType, Ts...>
constexpr explicit TOptional(FInPlace, Ts&&... Args)
: bIsValid(true)
{
new(&Value) OptionalType(Forward<Types>(Args)...);
new(&Value) OptionalType(Forward<Ts>(Args)...);
}
template <typename T = OptionalType> requires CConstructibleFrom<OptionalType, T&&>
@ -296,8 +296,8 @@ constexpr TOptional<T> MakeOptional(T&& InValue)
return TOptional<T>(Forward<T>(InValue));
}
template <typename T, typename... Types> requires CDestructible<T> && CConstructibleFrom<T, Types...>
constexpr TOptional<T> MakeOptional(Types&&... Args)
template <typename T, typename... Ts> requires CDestructible<T> && CConstructibleFrom<T, Ts...>
constexpr TOptional<T> MakeOptional(Ts&&... Args)
{
return TOptional<T>(InPlace, Forward<T>(Args)...);
}

View File

@ -43,10 +43,10 @@ public:
constexpr operator ReferencedType&() const { return *Pointer; }
constexpr ReferencedType& Get() const { return *Pointer; }
template <typename... Types>
constexpr TInvokeResult<ReferencedType&, Types...> operator()(Types&&... Args) const
template <typename... Ts>
constexpr TInvokeResult<ReferencedType&, Ts...> operator()(Ts&&... Args) const
{
return Invoke(Get(), Forward<Types>(Args)...);
return Invoke(Get(), Forward<Ts>(Args)...);
}
constexpr size_t GetTypeHash() const requires CHashable<ReferencedType>
@ -155,9 +155,9 @@ public:
constexpr TOptional(FInvalid) : TOptional() { }
template <typename... Types> requires CConstructibleFrom<OptionalType, Types...>
constexpr explicit TOptional(FInPlace, Types&&... Args)
: Reference(Forward<Types>(Args)...)
template <typename... Ts> requires CConstructibleFrom<OptionalType, Ts...>
constexpr explicit TOptional(FInPlace, Ts&&... Args)
: Reference(Forward<Ts>(Args)...)
{ }
template <typename T = OptionalType> requires CConstructibleFrom<OptionalType, T&&>

View File

@ -16,13 +16,13 @@ NAMESPACE_MODULE_BEGIN(Utility)
#define RS_TUPLE_ELEMENT_STATIC_ALIAS 1
template <typename... Types>
template <typename... Ts>
class TTuple;
NAMESPACE_PRIVATE_BEGIN
template <typename T > struct TIsTTuple : FFalse { };
template <typename... Types> struct TIsTTuple<TTuple<Types...>> : FTrue { };
template <typename... Ts> struct TIsTTuple<TTuple<Ts...>> : FTrue { };
struct FForwardingConstructor { explicit FForwardingConstructor() = default; };
struct FOtherTupleConstructor { explicit FOtherTupleConstructor() = default; };
@ -33,74 +33,74 @@ inline constexpr FOtherTupleConstructor OtherTupleConstructor{ };
template <typename TupleType>
struct TTupleArityImpl;
template <typename... Types>
struct TTupleArityImpl<TTuple<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TTupleArityImpl<TTuple<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename... Types>
struct TTupleArityImpl<const TTuple<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TTupleArityImpl<const TTuple<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename... Types>
struct TTupleArityImpl<volatile TTuple<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TTupleArityImpl<volatile TTuple<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename... Types>
struct TTupleArityImpl<const volatile TTuple<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TTupleArityImpl<const volatile TTuple<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename T, typename TupleType>
struct TTupleIndexImpl;
template <typename T, typename U, typename... Types>
struct TTupleIndexImpl<T, TTuple<U, Types...>> : TConstant<size_t, TTupleIndexImpl<T, TTuple<Types...>>::Value + 1>
template <typename T, typename U, typename... Ts>
struct TTupleIndexImpl<T, TTuple<U, Ts...>> : TConstant<size_t, TTupleIndexImpl<T, TTuple<Ts...>>::Value + 1>
{
static_assert(sizeof...(Types) != 0, "Non-existent types in tuple");
static_assert(sizeof...(Ts) != 0, "Non-existent types in tuple");
};
template <typename T, typename... Types>
struct TTupleIndexImpl<T, TTuple<T, Types...>> : TConstant<size_t, 0>
template <typename T, typename... Ts>
struct TTupleIndexImpl<T, TTuple<T, Ts...>> : TConstant<size_t, 0>
{
static_assert((true && ... && !CSameAs<T, Types>), "Duplicate type in tuple");
static_assert((true && ... && !CSameAs<T, Ts>), "Duplicate type in tuple");
};
template <typename T>
struct TTupleIndexImpl<T, TTuple<>> : TConstant<size_t, INDEX_NONE> { };
template <typename T, typename... Types>
struct TTupleIndexImpl<T, const TTuple<Types...>> : TTupleIndexImpl<T, TTuple<Types...>> { };
template <typename T, typename... Ts>
struct TTupleIndexImpl<T, const TTuple<Ts...>> : TTupleIndexImpl<T, TTuple<Ts...>> { };
template <typename T, typename... Types>
struct TTupleIndexImpl<T, volatile TTuple<Types...>> : TTupleIndexImpl<T, TTuple<Types...>> { };
template <typename T, typename... Ts>
struct TTupleIndexImpl<T, volatile TTuple<Ts...>> : TTupleIndexImpl<T, TTuple<Ts...>> { };
template <typename T, typename... Types>
struct TTupleIndexImpl<T, const volatile TTuple<Types...>> : TTupleIndexImpl<T, TTuple<Types...>> { };
template <typename T, typename... Ts>
struct TTupleIndexImpl<T, const volatile TTuple<Ts...>> : TTupleIndexImpl<T, TTuple<Ts...>> { };
template <size_t I, typename TupleType>
struct TTupleElementImpl;
template <size_t I, typename T, typename... Types>
struct TTupleElementImpl<I, TTuple<T, Types...>>
template <size_t I, typename T, typename... Ts>
struct TTupleElementImpl<I, TTuple<T, Ts...>>
{
static_assert(I < sizeof...(Types) + 1, "Invalid index in tuple");
using Type = TTupleElementImpl<I - 1, TTuple<Types...>>::Type;
static_assert(I < sizeof...(Ts) + 1, "Invalid index in tuple");
using Type = TTupleElementImpl<I - 1, TTuple<Ts...>>::Type;
};
template <typename T, typename... Types>
struct TTupleElementImpl<0, TTuple<T, Types...>> { using Type = T; };
template <typename T, typename... Ts>
struct TTupleElementImpl<0, TTuple<T, Ts...>> { using Type = T; };
template <size_t I, typename... Types>
struct TTupleElementImpl<I, TTuple<Types...>> { };
template <size_t I, typename... Ts>
struct TTupleElementImpl<I, TTuple<Ts...>> { };
template <>
struct TTupleElementImpl<0, TTuple<>> { };
template <size_t I, typename... Types>
struct TTupleElementImpl<I, const TTuple<Types...>> { using Type = TAddConst<typename TTupleElementImpl<I, TTuple<Types...>>::Type>; };
template <size_t I, typename... Ts>
struct TTupleElementImpl<I, const TTuple<Ts...>> { using Type = TAddConst<typename TTupleElementImpl<I, TTuple<Ts...>>::Type>; };
template <size_t I, typename... Types>
struct TTupleElementImpl<I, volatile TTuple<Types...>> { using Type = TAddVolatile<typename TTupleElementImpl<I, TTuple<Types...>>::Type>; };
template <size_t I, typename... Ts>
struct TTupleElementImpl<I, volatile TTuple<Ts...>> { using Type = TAddVolatile<typename TTupleElementImpl<I, TTuple<Ts...>>::Type>; };
template <size_t I, typename... Types>
struct TTupleElementImpl<I, const volatile TTuple<Types...>> { using Type = TAddCV<typename TTupleElementImpl<I, TTuple<Types...>>::Type>; };
template <size_t I, typename... Ts>
struct TTupleElementImpl<I, const volatile TTuple<Ts...>> { using Type = TAddCV<typename TTupleElementImpl<I, TTuple<Ts...>>::Type>; };
template <bool bTrue, typename... Types>
template <bool bTrue, typename... Ts>
struct TTupleConvertCopy : FTrue { };
template <typename T, typename U>
@ -110,7 +110,7 @@ struct TTupleConvertCopy<false, T, U>
|| CSameAs<T, U>)>
{ };
template <bool bTrue, typename... Types>
template <bool bTrue, typename... Ts>
struct TTupleConvertMove : FTrue { };
template <typename T, typename U>
@ -202,17 +202,17 @@ DEFINE_TTupleBasicElement(0xF, Sixteenth);
#endif
template <typename... Types>
constexpr TTuple<TUnwrapRefDecay<Types>...> MakeTupleImpl(Types&&... Args)
template <typename... Ts>
constexpr TTuple<TUnwrapRefDecay<Ts>...> MakeTupleImpl(Ts&&... Args)
{
return TTuple<TUnwrapRefDecay<Types>...>(Forward<Types>(Args)...);
return TTuple<TUnwrapRefDecay<Ts>...>(Forward<Ts>(Args)...);
}
template <typename Indices, typename... Types>
template <typename Indices, typename... Ts>
class TTupleImpl;
template <size_t... Indices, typename... Types>
class TTupleImpl<TIndexSequence<Indices...>, Types...> : public TTupleBasicElement<Types, Indices>...
template <size_t... Indices, typename... Ts>
class TTupleImpl<TIndexSequence<Indices...>, Ts...> : public TTupleBasicElement<Ts, Indices>...
{
protected:
@ -220,12 +220,12 @@ protected:
template <typename... ArgTypes>
explicit TTupleImpl(FForwardingConstructor, ArgTypes&&... Args)
: TTupleBasicElement<Types, Indices>(Forward<ArgTypes>(Args))...
: TTupleBasicElement<Ts, Indices>(Forward<ArgTypes>(Args))...
{ }
template <typename TupleType>
explicit TTupleImpl(FOtherTupleConstructor, TupleType&& InValue)
: TTupleBasicElement<Types, Indices>(Forward<TupleType>(InValue).template GetValue<Indices>())...
: TTupleBasicElement<Ts, Indices>(Forward<TupleType>(InValue).template GetValue<Indices>())...
{ }
TTupleImpl(const TTupleImpl&) = default;
@ -236,7 +236,7 @@ protected:
};
template <typename Indices, typename... Types>
template <typename Indices, typename... Ts>
class TTupleHelper;
template <size_t... Indices>
@ -300,51 +300,51 @@ inline constexpr size_t TTupleIndex = NAMESPACE_PRIVATE::TTupleIndexImpl<T, Tupl
template <size_t I, typename TupleType>
using TTupleElement = typename NAMESPACE_PRIVATE::TTupleElementImpl<I, TupleType>::Type;
template <typename... Types>
class TTuple : public NAMESPACE_PRIVATE::TTupleImpl<TIndexSequenceFor<Types...>, Types...>
template <typename... Ts>
class TTuple : public NAMESPACE_PRIVATE::TTupleImpl<TIndexSequenceFor<Ts...>, Ts...>
{
private:
using Super = NAMESPACE_PRIVATE::TTupleImpl<TIndexSequenceFor<Types...>, Types...>;
using Helper = NAMESPACE_PRIVATE::TTupleHelper<TIndexSequenceFor<Types...>>;
using Super = NAMESPACE_PRIVATE::TTupleImpl<TIndexSequenceFor<Ts...>, Ts...>;
using Helper = NAMESPACE_PRIVATE::TTupleHelper<TIndexSequenceFor<Ts...>>;
public:
TTuple() = default;
template <typename... ArgTypes> requires (sizeof...(Types) >= 1) && (sizeof...(ArgTypes) == sizeof...(Types))
&& (true && ... && CConstructibleFrom<Types, ArgTypes&&>)
constexpr explicit (!(true && ... && CConvertibleTo<ArgTypes&&, Types>)) TTuple(ArgTypes&&... Args)
template <typename... ArgTypes> requires (sizeof...(Ts) >= 1) && (sizeof...(ArgTypes) == sizeof...(Ts))
&& (true && ... && CConstructibleFrom<Ts, ArgTypes&&>)
constexpr explicit (!(true && ... && CConvertibleTo<ArgTypes&&, Ts>)) TTuple(ArgTypes&&... Args)
: Super(NAMESPACE_PRIVATE::ForwardingConstructor, Forward<ArgTypes>(Args)...)
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Types))
&& (true && ... && CConstructibleFrom<Types, const OtherTypes&>)
&& NAMESPACE_PRIVATE::TTupleConvertCopy<sizeof...(Types) != 1, Types..., OtherTypes...>::Value
constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Types>)) TTuple(const TTuple<OtherTypes...>& InValue)
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts))
&& (true && ... && CConstructibleFrom<Ts, const OtherTypes&>)
&& NAMESPACE_PRIVATE::TTupleConvertCopy<sizeof...(Ts) != 1, Ts..., OtherTypes...>::Value
constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Ts>)) TTuple(const TTuple<OtherTypes...>& InValue)
: Super(NAMESPACE_PRIVATE::OtherTupleConstructor, InValue)
{ }
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Types))
&& (true && ... && CConstructibleFrom<Types, OtherTypes&&>)
&& NAMESPACE_PRIVATE::TTupleConvertMove<sizeof...(Types) != 1, Types..., OtherTypes...>::Value
constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Types>)) TTuple(TTuple<OtherTypes...>&& InValue)
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts))
&& (true && ... && CConstructibleFrom<Ts, OtherTypes&&>)
&& NAMESPACE_PRIVATE::TTupleConvertMove<sizeof...(Ts) != 1, Ts..., OtherTypes...>::Value
constexpr explicit (!(true && ... && CConvertibleTo<OtherTypes&&, Ts>)) TTuple(TTuple<OtherTypes...>&& InValue)
: Super(NAMESPACE_PRIVATE::OtherTupleConstructor, MoveTemp(InValue))
{ }
TTuple(const TTuple&) = default;
TTuple(TTuple&&) = default;
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Types))
&& (true && ... && CAssignableFrom<Types&, const OtherTypes&>)
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts))
&& (true && ... && CAssignableFrom<Ts&, const OtherTypes&>)
constexpr TTuple& operator=(const TTuple<OtherTypes...>& InValue)
{
Helper::Assign(*this, InValue);
return *this;
}
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Types))
&& (true && ... && CAssignableFrom<Types&, OtherTypes&&>)
template <typename... OtherTypes> requires (sizeof...(OtherTypes) == sizeof...(Ts))
&& (true && ... && CAssignableFrom<Ts&, OtherTypes&&>)
constexpr TTuple& operator=(TTuple<OtherTypes...>&& InValue)
{
Helper::Assign(*this, MoveTemp(InValue));
@ -354,111 +354,111 @@ public:
TTuple& operator=(const TTuple&) = default;
TTuple& operator=(TTuple&&) = default;
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const & { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const && { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Types...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const & { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>& >(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { return static_cast< NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const && { return static_cast<const NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile NAMESPACE_PRIVATE::TTupleBasicElement<TTupleElement<I, TTuple<Ts...>>, I>&&>(*this).GetValue(); }
template <typename T> constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const & { return static_cast<const TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const && { return static_cast<const TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Types...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() & { return static_cast< TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const & { return static_cast<const TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() volatile& { return static_cast< volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const volatile& { return static_cast<const volatile TTuple& >(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() && { return static_cast< TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const && { return static_cast<const TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() volatile&& { return static_cast< volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename T> constexpr decltype(auto) GetValue() const volatile&& { return static_cast<const volatile TTuple&&>(*this).GetValue<TTupleIndex<T, TTuple<Ts...>>>(); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Types...> constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) & { return Helper::Apply(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) const & { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) volatile& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) const volatile& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) && { return Helper::Apply(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) const && { return Helper::Apply(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) volatile&& { return Helper::Apply(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires CInvocable<F, Ts...> constexpr decltype(auto) Apply(F&& Func) const volatile&& { return Helper::Apply(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward<F>(Func), static_cast< TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward<F>(Func), static_cast< volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward<F>(Func), static_cast< TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward<F>(Func), static_cast< volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Types...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyAfter(Forward<F>(Func), static_cast< TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyAfter(Forward<F>(Func), static_cast< volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyAfter(Forward<F>(Func), static_cast< TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyAfter(Forward<F>(Func), static_cast< volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, ArgTypes..., Ts...> constexpr decltype(auto) ApplyAfter(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyAfter(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward<F>(Func), static_cast< TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward<F>(Func), static_cast< volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward<F>(Func), static_cast< TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward<F>(Func), static_cast< volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Types..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) & { return Helper::ApplyBefore(Forward<F>(Func), static_cast< TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const & { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile& { return Helper::ApplyBefore(Forward<F>(Func), static_cast< volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile& { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const volatile TTuple& >(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) && { return Helper::ApplyBefore(Forward<F>(Func), static_cast< TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const && { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) volatile&& { return Helper::ApplyBefore(Forward<F>(Func), static_cast< volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F, typename... ArgTypes> requires CInvocable<F, Ts..., ArgTypes...> constexpr decltype(auto) ApplyBefore(F&& Func, ArgTypes&&... Args) const volatile&& { return Helper::ApplyBefore(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this), Forward<ArgTypes>(Args)...); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Types> && !CSameAs<void, TInvokeResult<F, Types>>)) constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) & { return Helper::Transform(Forward<F>(Func), static_cast< TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const & { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) volatile& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const volatile& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple& >(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) && { return Helper::Transform(Forward<F>(Func), static_cast< TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const && { return Helper::Transform(Forward<F>(Func), static_cast<const TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) volatile&& { return Helper::Transform(Forward<F>(Func), static_cast< volatile TTuple&&>(*this)); }
template <typename F> requires (true && ... && (CInvocable<F, Ts> && !CSameAs<void, TInvokeResult<F, Ts>>)) constexpr decltype(auto) Transform(F&& Func) const volatile&& { return Helper::Transform(Forward<F>(Func), static_cast<const volatile TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() & { return Helper::template Construct<T>(static_cast< TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() const & { return Helper::template Construct<T>(static_cast<const TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() volatile& { return Helper::template Construct<T>(static_cast< volatile TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() const volatile& { return Helper::template Construct<T>(static_cast<const volatile TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() && { return Helper::template Construct<T>(static_cast< TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() const && { return Helper::template Construct<T>(static_cast<const TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() volatile&& { return Helper::template Construct<T>(static_cast< volatile TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Types...> constexpr T Construct() const volatile&& { return Helper::template Construct<T>(static_cast<const volatile TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() & { return Helper::template Construct<T>(static_cast< TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() const & { return Helper::template Construct<T>(static_cast<const TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() volatile& { return Helper::template Construct<T>(static_cast< volatile TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() const volatile& { return Helper::template Construct<T>(static_cast<const volatile TTuple& >(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() && { return Helper::template Construct<T>(static_cast< TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() const && { return Helper::template Construct<T>(static_cast<const TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> constexpr T Construct() volatile&& { return Helper::template Construct<T>(static_cast< volatile TTuple&&>(*this)); }
template <typename T> requires CConstructibleFrom<T, Ts...> 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>)
constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Ts>)
{
return [this]<size_t... Indices>(TIndexSequence<Indices...>) -> size_t
{
return HashCombine(NAMESPACE_REDCRAFT::GetTypeHash(GetValue<Indices>())...);
}
(TMakeIndexSequence<sizeof...(Types)>());
(TMakeIndexSequence<sizeof...(Ts)>());
}
constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible<Types>&& CSwappable<Types>))
constexpr void Swap(TTuple& InValue) requires (true && ... && (CMoveConstructible<Ts>&& CSwappable<Ts>))
{
[&A = *this, &B = InValue]<size_t... Indices>(TIndexSequence<Indices...>)
{
((NAMESPACE_REDCRAFT::Swap(A.template GetValue<Indices>(), B.template GetValue<Indices>())), ...);
}
(TMakeIndexSequence<sizeof...(Types)>());
(TMakeIndexSequence<sizeof...(Ts)>());
}
};
template <typename... Types>
TTuple(Types...) -> TTuple<Types...>;
template <typename... Ts>
TTuple(Ts...) -> TTuple<Ts...>;
template <typename T, typename U>
using TPair = TTuple<T, U>;
template <typename... Types>
constexpr TTuple<TUnwrapRefDecay<Types>...> MakeTuple(Types&&... Args)
template <typename... Ts>
constexpr TTuple<TUnwrapRefDecay<Ts>...> MakeTuple(Ts&&... Args)
{
return TTuple<TUnwrapRefDecay<Types>...>(Forward<Types>(Args)...);
return TTuple<TUnwrapRefDecay<Ts>...>(Forward<Ts>(Args)...);
}
template <typename... Types>
constexpr TTuple<Types&...> Tie(Types&... Args)
template <typename... Ts>
constexpr TTuple<Ts&...> Tie(Ts&... Args)
{
return TTuple<Types&...>(Args...);
return TTuple<Ts&...>(Args...);
}
template <typename... Types>
constexpr TTuple<Types&&...> ForwardAsTuple(Types&&... Args)
template <typename... Ts>
constexpr TTuple<Ts&&...> ForwardAsTuple(Ts&&... Args)
{
return TTuple<Types&&...>(Forward<Types>(Args)...);
return TTuple<Ts&&...>(Forward<Ts>(Args)...);
}
NAMESPACE_PRIVATE_BEGIN
@ -468,16 +468,16 @@ struct FTupleEndFlag { };
template <typename... TTupleTypes>
struct TTupleCatResultImpl;
template <typename... Types, typename... TTupleTypes>
struct TTupleCatResultImpl<TTuple<Types...>, TTupleTypes...>
template <typename... Ts, typename... TTupleTypes>
struct TTupleCatResultImpl<TTuple<Ts...>, TTupleTypes...>
{
using Type = typename TTupleCatResultImpl<TTupleTypes..., Types...>::Type;
using Type = typename TTupleCatResultImpl<TTupleTypes..., Ts...>::Type;
};
template <typename... Types>
struct TTupleCatResultImpl<FTupleEndFlag, Types...>
template <typename... Ts>
struct TTupleCatResultImpl<FTupleEndFlag, Ts...>
{
using Type = TTuple<Types...>;
using Type = TTuple<Ts...>;
};
template <typename R, typename Indices>
@ -637,8 +637,8 @@ NAMESPACE_REDCRAFT_END
NAMESPACE_STD_BEGIN
// Support structure binding, should not be directly used
template <typename... Types> struct tuple_size<NAMESPACE_REDCRAFT::TTuple<Types...>> : integral_constant<size_t, NAMESPACE_REDCRAFT::TTupleArity<NAMESPACE_REDCRAFT::TTuple<Types...>>> { };
template <size_t I, typename... Types> struct tuple_element<I, NAMESPACE_REDCRAFT::TTuple<Types...>> { using type = NAMESPACE_REDCRAFT::TTupleElement<I, NAMESPACE_REDCRAFT::TTuple<Types...>>; };
template <typename... Ts> struct tuple_size<NAMESPACE_REDCRAFT::TTuple<Ts...>> : integral_constant<size_t, NAMESPACE_REDCRAFT::TTupleArity<NAMESPACE_REDCRAFT::TTuple<Ts...>>> { };
template <size_t I, typename... Ts> struct tuple_element<I, NAMESPACE_REDCRAFT::TTuple<Ts...>> { using type = NAMESPACE_REDCRAFT::TTupleElement<I, NAMESPACE_REDCRAFT::TTuple<Ts...>>; };
NAMESPACE_STD_END
@ -647,14 +647,14 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
// Support structure binding, should not be directly used
template <size_t Index, typename ...Types> constexpr decltype(auto) get( TTuple<Types...>& InValue) { return static_cast< TTuple<Types...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get(const TTuple<Types...>& InValue) { return static_cast<const TTuple<Types...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get( volatile TTuple<Types...>& InValue) { return static_cast< volatile TTuple<Types...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get(const volatile TTuple<Types...>& InValue) { return static_cast<const volatile TTuple<Types...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get( TTuple<Types...>&& InValue) { return static_cast< TTuple<Types...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get(const TTuple<Types...>&& InValue) { return static_cast<const TTuple<Types...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get( volatile TTuple<Types...>&& InValue) { return static_cast< volatile TTuple<Types...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Types> constexpr decltype(auto) get(const volatile TTuple<Types...>&& InValue) { return static_cast<const volatile TTuple<Types...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( TTuple<Ts...>& InValue) { return static_cast< TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const TTuple<Ts...>& InValue) { return static_cast<const TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( volatile TTuple<Ts...>& InValue) { return static_cast< volatile TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const volatile TTuple<Ts...>& InValue) { return static_cast<const volatile TTuple<Ts...>& >(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( TTuple<Ts...>&& InValue) { return static_cast< TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const TTuple<Ts...>&& InValue) { return static_cast<const TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get( volatile TTuple<Ts...>&& InValue) { return static_cast< volatile TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
template <size_t Index, typename ...Ts> constexpr decltype(auto) get(const volatile TTuple<Ts...>&& InValue) { return static_cast<const volatile TTuple<Ts...>&&>(InValue).template GetValue<Index>(); }
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)

View File

@ -39,8 +39,8 @@ constexpr size_t HashCombine(size_t A, size_t C)
return C;
}
template <typename... Types> requires (true && ... && CConvertibleTo<Types, size_t>)
constexpr size_t HashCombine(size_t A, size_t C, Types... InOther)
template <typename... Ts> requires (true && ... && CConvertibleTo<Ts, size_t>)
constexpr size_t HashCombine(size_t A, size_t C, Ts... InOther)
{
size_t B = HashCombine(A, C);
return HashCombine(B, InOther...);

View File

@ -13,92 +13,92 @@ NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename... Types> requires (true && ... && CDestructible<Types>)
template <typename... Ts> requires (true && ... && CDestructible<Ts>)
class TVariant;
NAMESPACE_PRIVATE_BEGIN
template <typename T > struct TIsTVariant : FFalse { };
template <typename... Types> struct TIsTVariant<TVariant<Types...>> : FTrue { };
template <typename... Ts> struct TIsTVariant<TVariant<Ts...>> : FTrue { };
template <typename TupleType>
struct TVariantNumImpl;
template <typename... Types>
struct TVariantNumImpl<TVariant<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TVariantNumImpl<TVariant<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename... Types>
struct TVariantNumImpl<const TVariant<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TVariantNumImpl<const TVariant<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename... Types>
struct TVariantNumImpl<volatile TVariant<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TVariantNumImpl<volatile TVariant<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename... Types>
struct TVariantNumImpl<const volatile TVariant<Types...>> : TConstant<size_t, sizeof...(Types)> { };
template <typename... Ts>
struct TVariantNumImpl<const volatile TVariant<Ts...>> : TConstant<size_t, sizeof...(Ts)> { };
template <typename T, typename TupleType>
struct TVariantIndexImpl;
template <typename T, typename U, typename... Types>
struct TVariantIndexImpl<T, TVariant<U, Types...>> : TConstant<size_t, TVariantIndexImpl<T, TVariant<Types...>>::Value + 1>
template <typename T, typename U, typename... Ts>
struct TVariantIndexImpl<T, TVariant<U, Ts...>> : TConstant<size_t, TVariantIndexImpl<T, TVariant<Ts...>>::Value + 1>
{
static_assert(sizeof...(Types) != 0, "Non-existent types in variant");
static_assert(sizeof...(Ts) != 0, "Non-existent types in variant");
};
template <typename T, typename... Types>
struct TVariantIndexImpl<T, TVariant<T, Types...>> : TConstant<size_t, 0>
template <typename T, typename... Ts>
struct TVariantIndexImpl<T, TVariant<T, Ts...>> : TConstant<size_t, 0>
{
static_assert((true && ... && !CSameAs<T, Types>), "Duplicate type in variant");
static_assert((true && ... && !CSameAs<T, Ts>), "Duplicate type in variant");
};
template <typename T>
struct TVariantIndexImpl<T, TVariant<>> : TConstant<size_t, INDEX_NONE> { };
template <typename T, typename... Types>
struct TVariantIndexImpl<T, const TVariant<Types...>> : TVariantIndexImpl<T, TVariant<Types...>> { };
template <typename T, typename... Ts>
struct TVariantIndexImpl<T, const TVariant<Ts...>> : TVariantIndexImpl<T, TVariant<Ts...>> { };
template <typename T, typename... Types>
struct TVariantIndexImpl<T, volatile TVariant<Types...>> : TVariantIndexImpl<T, TVariant<Types...>> { };
template <typename T, typename... Ts>
struct TVariantIndexImpl<T, volatile TVariant<Ts...>> : TVariantIndexImpl<T, TVariant<Ts...>> { };
template <typename T, typename... Types>
struct TVariantIndexImpl<T, const volatile TVariant<Types...>> : TVariantIndexImpl<T, TVariant<Types...>> { };
template <typename T, typename... Ts>
struct TVariantIndexImpl<T, const volatile TVariant<Ts...>> : TVariantIndexImpl<T, TVariant<Ts...>> { };
template <size_t I, typename TupleType>
struct TVariantAlternativeImpl;
template <size_t I, typename T, typename... Types>
struct TVariantAlternativeImpl<I, TVariant<T, Types...>>
template <size_t I, typename T, typename... Ts>
struct TVariantAlternativeImpl<I, TVariant<T, Ts...>>
{
static_assert(I < sizeof...(Types) + 1, "Invalid index in variant");
using Type = TVariantAlternativeImpl<I - 1, TVariant<Types...>>::Type;
static_assert(I < sizeof...(Ts) + 1, "Invalid index in variant");
using Type = TVariantAlternativeImpl<I - 1, TVariant<Ts...>>::Type;
};
template <typename T, typename... Types>
struct TVariantAlternativeImpl<0, TVariant<T, Types...>> { using Type = T; };
template <typename T, typename... Ts>
struct TVariantAlternativeImpl<0, TVariant<T, Ts...>> { using Type = T; };
template <size_t I, typename... Types>
struct TVariantAlternativeImpl<I, TVariant<Types...>> { };
template <size_t I, typename... Ts>
struct TVariantAlternativeImpl<I, TVariant<Ts...>> { };
template <>
struct TVariantAlternativeImpl<0, TVariant<>> { };
template <size_t I, typename... Types>
struct TVariantAlternativeImpl<I, const TVariant<Types...>> { using Type = TAddConst<typename TVariantAlternativeImpl<I, TVariant<Types...>>::Type>; };
template <size_t I, typename... Ts>
struct TVariantAlternativeImpl<I, const TVariant<Ts...>> { using Type = TAddConst<typename TVariantAlternativeImpl<I, TVariant<Ts...>>::Type>; };
template <size_t I, typename... Types>
struct TVariantAlternativeImpl<I, volatile TVariant<Types...>> { using Type = TAddVolatile<typename TVariantAlternativeImpl<I, TVariant<Types...>>::Type>; };
template <size_t I, typename... Ts>
struct TVariantAlternativeImpl<I, volatile TVariant<Ts...>> { using Type = TAddVolatile<typename TVariantAlternativeImpl<I, TVariant<Ts...>>::Type>; };
template <size_t I, typename... Types>
struct TVariantAlternativeImpl<I, const volatile TVariant<Types...>> { using Type = TAddCV<typename TVariantAlternativeImpl<I, TVariant<Types...>>::Type>; };
template <size_t I, typename... Ts>
struct TVariantAlternativeImpl<I, const volatile TVariant<Ts...>> { using Type = TAddCV<typename TVariantAlternativeImpl<I, TVariant<Ts...>>::Type>; };
template <typename T, typename... Types>
template <typename T, typename... Ts>
struct TVariantSelectedType;
template <typename T, typename U, typename... Types>
struct TVariantSelectedType<T, U, Types...>
template <typename T, typename U, typename... Ts>
struct TVariantSelectedType<T, U, Ts...>
{
using TypeAlternativeA = TConditional<CConstructibleFrom<U, T&&>, U, void>;
using TypeAlternativeB = typename TVariantSelectedType<T, Types...>::Type;
using TypeAlternativeB = typename TVariantSelectedType<T, Ts...>::Type;
using Type = TConditional<CSameAs<TRemoveCVRef<TypeAlternativeA>, void>, TypeAlternativeB,
TConditional<CSameAs<TRemoveCVRef<TypeAlternativeB>, void>, TypeAlternativeA,
@ -138,7 +138,7 @@ inline constexpr size_t TVariantIndex = NAMESPACE_PRIVATE::TVariantIndexImpl<T,
template <size_t I, typename VariantType>
using TVariantAlternative = typename NAMESPACE_PRIVATE::TVariantAlternativeImpl<I, VariantType>::Type;
template <typename... Types> requires (true && ... && CDestructible<Types>)
template <typename... Ts> requires (true && ... && CDestructible<Ts>)
class TVariant
{
public:
@ -147,44 +147,44 @@ public:
constexpr TVariant(FInvalid) : TVariant() { };
constexpr TVariant(const TVariant& InValue) requires (true && ... && CCopyConstructible<Types>)
constexpr TVariant(const TVariant& InValue) requires (true && ... && CCopyConstructible<Ts>)
: TypeIndex(static_cast<uint8>(InValue.GetIndex()))
{
if (IsValid()) CopyConstructImpl[InValue.GetIndex()](&Value, &InValue.Value);
}
constexpr TVariant(TVariant&& InValue) requires (true && ... && CMoveConstructible<Types>)
constexpr TVariant(TVariant&& InValue) requires (true && ... && CMoveConstructible<Ts>)
: TypeIndex(static_cast<uint8>(InValue.GetIndex()))
{
if (IsValid()) MoveConstructImpl[InValue.GetIndex()](&Value, &InValue.Value);
}
template <size_t I, typename... ArgTypes> requires (I < sizeof...(Types))
&& CConstructibleFrom<TVariantAlternative<I, TVariant<Types...>>, ArgTypes...>
template <size_t I, typename... ArgTypes> requires (I < sizeof...(Ts))
&& CConstructibleFrom<TVariantAlternative<I, TVariant<Ts...>>, ArgTypes...>
constexpr explicit TVariant(TInPlaceIndex<I>, ArgTypes&&... Args)
: TypeIndex(I)
{
using SelectedType = TVariantAlternative<I, TVariant<Types...>>;
using SelectedType = TVariantAlternative<I, TVariant<Ts...>>;
new(&Value) SelectedType(Forward<ArgTypes>(Args)...);
}
template <typename T, typename... ArgTypes> requires CConstructibleFrom<T, ArgTypes...>
constexpr explicit TVariant(TInPlaceType<T>, ArgTypes&&... Args)
: TVariant(InPlaceIndex<TVariantIndex<T, TVariant<Types...>>>, Forward<ArgTypes>(Args)...)
: TVariant(InPlaceIndex<TVariantIndex<T, TVariant<Ts...>>>, Forward<ArgTypes>(Args)...)
{ }
template <typename T> requires NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Types...>::Value
template <typename T> requires NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Ts...>::Value
&& (!CTInPlaceType<TRemoveCVRef<T>>) && (!CTInPlaceIndex<TRemoveCVRef<T>>)
&& (!CSameAs<TRemoveCVRef<T>, TVariant>)
constexpr TVariant(T&& InValue) : TVariant(InPlaceType<typename NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Types...>::Type>, Forward<T>(InValue))
constexpr TVariant(T&& InValue) : TVariant(InPlaceType<typename NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Ts...>::Type>, Forward<T>(InValue))
{ }
constexpr ~TVariant()
{
if constexpr (!(true && ... && CTriviallyDestructible<Types>)) Reset();
if constexpr (!(true && ... && CTriviallyDestructible<Ts>)) Reset();
}
constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CCopyConstructible<Types> && CCopyAssignable<Types>))
constexpr TVariant& operator=(const TVariant& InValue) requires (true && ... && (CCopyConstructible<Ts> && CCopyAssignable<Ts>))
{
if (&InValue == this) return *this;
@ -205,7 +205,7 @@ public:
return *this;
}
constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CMoveConstructible<Types> && CMoveAssignable<Types>))
constexpr TVariant& operator=(TVariant&& InValue) requires (true && ... && (CMoveConstructible<Ts> && CMoveAssignable<Ts>))
{
if (&InValue == this) return *this;
@ -226,29 +226,29 @@ public:
return *this;
}
template <typename T> requires NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Types...>::Value
template <typename T> requires NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Ts...>::Value
constexpr TVariant& operator=(T&& InValue)
{
using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Types...>::Type;
using SelectedType = typename NAMESPACE_PRIVATE::TVariantSelectedType<TRemoveReference<T>, Ts...>::Type;
if (GetIndex() == TVariantIndex<SelectedType, TVariant<Types...>>) GetValue<SelectedType>() = Forward<T>(InValue);
if (GetIndex() == TVariantIndex<SelectedType, TVariant<Ts...>>) GetValue<SelectedType>() = Forward<T>(InValue);
else
{
Reset();
new(&Value) SelectedType(Forward<T>(InValue));
TypeIndex = TVariantIndex<SelectedType, TVariant<Types...>>;
TypeIndex = TVariantIndex<SelectedType, TVariant<Ts...>>;
}
return *this;
}
template <size_t I, typename... ArgTypes> requires (I < sizeof...(Types))
&& CConstructibleFrom<TVariantAlternative<I, TVariant<Types...>>, ArgTypes...>
constexpr TVariantAlternative<I, TVariant<Types...>>& Emplace(ArgTypes&&... Args)
template <size_t I, typename... ArgTypes> requires (I < sizeof...(Ts))
&& CConstructibleFrom<TVariantAlternative<I, TVariant<Ts...>>, ArgTypes...>
constexpr TVariantAlternative<I, TVariant<Ts...>>& Emplace(ArgTypes&&... Args)
{
Reset();
using SelectedType = TVariantAlternative<I, TVariant<Types...>>;
using SelectedType = TVariantAlternative<I, TVariant<Ts...>>;
SelectedType* Result = new(&Value) SelectedType(Forward<ArgTypes>(Args)...);
TypeIndex = I;
@ -258,7 +258,7 @@ public:
template <typename T, typename... ArgTypes> requires CConstructibleFrom<T, ArgTypes...>
constexpr T& Emplace(ArgTypes&&... Args)
{
return Emplace<TVariantIndex<T, TVariant<Types...>>>(Forward<ArgTypes>(Args)...);
return Emplace<TVariantIndex<T, TVariant<Ts...>>>(Forward<ArgTypes>(Args)...);
}
constexpr const type_info& GetTypeInfo() const { return IsValid() ? *TypeInfos[GetIndex()] : typeid(void); }
@ -268,93 +268,93 @@ public:
constexpr explicit operator bool() const { return TypeIndex != 0xFF; }
template <size_t I> constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == I : false; }
template <typename T> constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TVariantIndex<T, TVariant<Types...>> : false; }
template <typename T> constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TVariantIndex<T, TVariant<Ts...>> : false; }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TVariantAlternative<I, TVariant<Types...>>*>(&Value); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TVariantAlternative<I, TVariant<Types...>>*>(&Value)); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast<const TVariantAlternative<I, TVariant<Types...>>*>(&Value); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast<const TVariantAlternative<I, TVariant<Types...>>*>(&Value)); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TVariantAlternative<I, TVariant<Ts...>>*>(&Value); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TVariantAlternative<I, TVariant<Ts...>>*>(&Value)); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast<const TVariantAlternative<I, TVariant<Ts...>>*>(&Value); }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast<const TVariantAlternative<I, TVariant<Ts...>>*>(&Value)); }
template <typename T> constexpr decltype(auto) GetValue() & { checkf(HoldsAlternative<T>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(&Value); }
template <typename T> constexpr decltype(auto) GetValue() && { checkf(HoldsAlternative<T>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< T*>(&Value)); }
template <typename T> constexpr decltype(auto) GetValue() const& { checkf(HoldsAlternative<T>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast<const T*>(&Value); }
template <typename T> constexpr decltype(auto) GetValue() const&& { checkf(HoldsAlternative<T>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast<const T*>(&Value)); }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) Get( TVariantAlternative<I, TVariant<Types...>>& DefaultValue) & { return HoldsAlternative<I>() ? GetValue<I>() : DefaultValue; }
template <size_t I> requires (I < sizeof...(Types)) constexpr decltype(auto) Get(const TVariantAlternative<I, TVariant<Types...>>& DefaultValue) const& { return HoldsAlternative<I>() ? GetValue<I>() : DefaultValue; }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) Get( TVariantAlternative<I, TVariant<Ts...>>& DefaultValue) & { return HoldsAlternative<I>() ? GetValue<I>() : DefaultValue; }
template <size_t I> requires (I < sizeof...(Ts)) constexpr decltype(auto) Get(const TVariantAlternative<I, TVariant<Ts...>>& DefaultValue) const& { return HoldsAlternative<I>() ? GetValue<I>() : DefaultValue; }
template <typename T> constexpr decltype(auto) Get( T& DefaultValue) & { return HoldsAlternative<T>() ? GetValue<T>() : DefaultValue; }
template <typename T> constexpr decltype(auto) Get(const T& DefaultValue) const& { return HoldsAlternative<T>() ? GetValue<T>() : DefaultValue; }
template <typename F> requires (true && ... && CInvocable<F, Types>)
template <typename F> requires (true && ... && CInvocable<F, Ts>)
FORCEINLINE decltype(auto) Visit(F&& Func) &
{
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
using ReturnType = TCommonType<TInvokeResult<F, Ts>...>;
using FInvokeImpl = ReturnType(*)(F&&, void*);
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), *reinterpret_cast<Types*>(This)); }... };
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), *reinterpret_cast<Ts*>(This)); }... };
return InvokeImpl[GetIndex()](Forward<F>(Func), &Value);
}
template <typename F> requires (true && ... && CInvocable<F, Types>)
template <typename F> requires (true && ... && CInvocable<F, Ts>)
FORCEINLINE decltype(auto) Visit(F&& Func) &&
{
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
using ReturnType = TCommonType<TInvokeResult<F, Ts>...>;
using FInvokeImpl = ReturnType(*)(F&&, void*);
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), MoveTemp(*reinterpret_cast<Types*>(This))); }... };
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), MoveTemp(*reinterpret_cast<Ts*>(This))); }... };
return InvokeImpl[GetIndex()](Forward<F>(Func), &Value);
}
template <typename F> requires (true && ... && CInvocable<F, Types>)
template <typename F> requires (true && ... && CInvocable<F, Ts>)
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()."));
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
using ReturnType = TCommonType<TInvokeResult<F, Ts>...>;
using FInvokeImpl = ReturnType(*)(F&&, const void*);
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), *reinterpret_cast<const Types*>(This)); }... };
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), *reinterpret_cast<const Ts*>(This)); }... };
return InvokeImpl[GetIndex()](Forward<F>(Func), &Value);
}
template <typename F> requires (true && ... && CInvocable<F, Types>)
template <typename F> requires (true && ... && CInvocable<F, Ts>)
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()."));
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
using ReturnType = TCommonType<TInvokeResult<F, Ts>...>;
using FInvokeImpl = ReturnType(*)(F&&, const void*);
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), MoveTemp(*reinterpret_cast<const Types*>(This))); }... };
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, const void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), MoveTemp(*reinterpret_cast<const Ts*>(This))); }... };
return InvokeImpl[GetIndex()](Forward<F>(Func), &Value);
}
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Types>)
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Ts>)
FORCEINLINE R Visit(F&& Func) & { return Visit(Forward<F>(Func)); }
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Types>)
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Ts>)
FORCEINLINE R Visit(F&& Func) && { return MoveTemp(*this).Visit(Forward<F>(Func)); }
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Types>)
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Ts>)
FORCEINLINE R Visit(F&& Func) const& { return Visit(Forward<F>(Func)); }
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Types>)
template <typename R, typename F> requires (true && ... && CInvocableResult<R, F, Ts>)
FORCEINLINE R Visit(F&& Func) const&& { return MoveTemp(*this).Visit(Forward<F>(Func)); }
constexpr void Reset()
{
if (GetIndex() == INDEX_NONE) return;
if constexpr (!(true && ... && CTriviallyDestructible<Types>))
if constexpr (!(true && ... && CTriviallyDestructible<Ts>))
{
DestroyImpl[GetIndex()](&Value);
}
@ -362,19 +362,19 @@ public:
TypeIndex = static_cast<uint8>(INDEX_NONE);
}
constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Types>)
constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Ts>)
{
if (!IsValid()) return 114514;
using NAMESPACE_REDCRAFT::GetTypeHash;
using FHashImpl = size_t(*)(const void*);
constexpr FHashImpl HashImpl[] = { [](const void* This) -> size_t { return GetTypeHash(*reinterpret_cast<const Types*>(This)); }... };
constexpr FHashImpl HashImpl[] = { [](const void* This) -> size_t { return GetTypeHash(*reinterpret_cast<const Ts*>(This)); }... };
return HashCombine(GetTypeHash(GetIndex()), HashImpl[GetIndex()](&Value));
}
constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible<Types> && CSwappable<Types>))
constexpr void Swap(TVariant& InValue) requires (true && ... && (CMoveConstructible<Ts> && CSwappable<Ts>))
{
if (!IsValid() && !InValue.IsValid()) return;
@ -397,7 +397,7 @@ public:
using NAMESPACE_REDCRAFT::Swap;
using FSwapImpl = void(*)(void*, void*);
constexpr FSwapImpl SwapImpl[] = { [](void* A, void* B) { Swap(*reinterpret_cast<Types*>(A), *reinterpret_cast<Types*>(B)); }... };
constexpr FSwapImpl SwapImpl[] = { [](void* A, void* B) { Swap(*reinterpret_cast<Ts*>(A), *reinterpret_cast<Ts*>(B)); }... };
SwapImpl[GetIndex()](&Value, &InValue.Value);
@ -411,7 +411,7 @@ public:
private:
static constexpr const type_info* TypeInfos[] = { &typeid(Types)... };
static constexpr const type_info* TypeInfos[] = { &typeid(Ts)... };
using FCopyConstructImpl = void(*)(void*, const void*);
using FMoveConstructImpl = void(*)(void*, void*);
@ -419,47 +419,47 @@ private:
using FMoveAssignImpl = void(*)(void*, void*);
using FDestroyImpl = void(*)(void* );
static constexpr FCopyConstructImpl CopyConstructImpl[] = { [](void* A, const void* B) { if constexpr (requires(Types* A, const Types* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast<Types*>(A), reinterpret_cast<const Types*>(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(Types).name()); }... };
static constexpr FMoveConstructImpl MoveConstructImpl[] = { [](void* A, void* B) { if constexpr (requires(Types* A, Types* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast<Types*>(A), reinterpret_cast< Types*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(Types).name()); }... };
static constexpr FCopyAssignImpl CopyAssignImpl[] = { [](void* A, const void* B) { if constexpr (requires(Types* A, const Types* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast<Types*>(A), reinterpret_cast<const Types*>(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(Types).name()); }... };
static constexpr FMoveAssignImpl MoveAssignImpl[] = { [](void* A, void* B) { if constexpr (requires(Types* A, Types* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast<Types*>(A), reinterpret_cast< Types*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(Types).name()); }... };
static constexpr FDestroyImpl DestroyImpl[] = { [](void* A ) { if constexpr (requires(Types* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast<Types*>(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(Types).name()); }... };
static constexpr FCopyConstructImpl CopyConstructImpl[] = { [](void* A, const void* B) { if constexpr (requires(Ts* A, const Ts* B) { Memory::CopyConstruct (A, B); }) Memory::CopyConstruct (reinterpret_cast<Ts*>(A), reinterpret_cast<const Ts*>(B)); else checkf(false, TEXT("The type '%s' is not copy constructible."), typeid(Ts).name()); }... };
static constexpr FMoveConstructImpl MoveConstructImpl[] = { [](void* A, void* B) { if constexpr (requires(Ts* A, Ts* B) { Memory::MoveConstruct (A, B); }) Memory::MoveConstruct (reinterpret_cast<Ts*>(A), reinterpret_cast< Ts*>(B)); else checkf(false, TEXT("The type '%s' is not move constructible."), typeid(Ts).name()); }... };
static constexpr FCopyAssignImpl CopyAssignImpl[] = { [](void* A, const void* B) { if constexpr (requires(Ts* A, const Ts* B) { Memory::CopyAssign (A, B); }) Memory::CopyAssign (reinterpret_cast<Ts*>(A), reinterpret_cast<const Ts*>(B)); else checkf(false, TEXT("The type '%s' is not copy assignable."), typeid(Ts).name()); }... };
static constexpr FMoveAssignImpl MoveAssignImpl[] = { [](void* A, void* B) { if constexpr (requires(Ts* A, Ts* B) { Memory::MoveAssign (A, B); }) Memory::MoveAssign (reinterpret_cast<Ts*>(A), reinterpret_cast< Ts*>(B)); else checkf(false, TEXT("The type '%s' is not move assignable."), typeid(Ts).name()); }... };
static constexpr FDestroyImpl DestroyImpl[] = { [](void* A ) { if constexpr (requires(Ts* A ) { Memory::Destruct (A ); }) Memory::Destruct (reinterpret_cast<Ts*>(A) ); else checkf(false, TEXT("The type '%s' is not destructible."), typeid(Ts).name()); }... };
TAlignedUnion<1, Types...> Value;
TAlignedUnion<1, Ts...> Value;
uint8 TypeIndex;
friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable<Types>)
friend constexpr bool operator==(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CEqualityComparable<Ts>)
{
if (LHS.GetIndex() != RHS.GetIndex()) return false;
if (LHS.IsValid() == false) return true;
using FCompareImpl = bool(*)(const void*, const void*);
constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> bool { return *reinterpret_cast<const Types*>(LHS) == *reinterpret_cast<const Types*>(RHS); }... };
constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> bool { return *reinterpret_cast<const Ts*>(LHS) == *reinterpret_cast<const Ts*>(RHS); }... };
return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value);
}
friend constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable<Types>)
friend constexpr partial_ordering operator<=>(const TVariant& LHS, const TVariant& RHS) requires (true && ... && CSynthThreeWayComparable<Ts>)
{
if (LHS.GetIndex() != RHS.GetIndex()) return partial_ordering::unordered;
if (LHS.IsValid() == false) return partial_ordering::equivalent;
using FCompareImpl = partial_ordering(*)(const void*, const void*);
constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> partial_ordering { return SynthThreeWayCompare(*reinterpret_cast<const Types*>(LHS), *reinterpret_cast<const Types*>(RHS)); }...};
constexpr FCompareImpl CompareImpl[] = { [](const void* LHS, const void* RHS) -> partial_ordering { return SynthThreeWayCompare(*reinterpret_cast<const Ts*>(LHS), *reinterpret_cast<const Ts*>(RHS)); }...};
return CompareImpl[LHS.GetIndex()](&LHS.Value, &RHS.Value);
}
};
template <typename T, typename... Types> requires (!CSameAs<T, TVariant<Types...>>) && CEqualityComparable<T>
constexpr bool operator==(const TVariant<Types...>& LHS, const T& RHS)
template <typename T, typename... Ts> requires (!CSameAs<T, TVariant<Ts...>>) && CEqualityComparable<T>
constexpr bool operator==(const TVariant<Ts...>& LHS, const T& RHS)
{
return LHS.template HoldsAlternative<T>() ? LHS.template GetValue<T>() == RHS : false;
}
template <typename... Types>
constexpr bool operator==(const TVariant<Types...>& LHS, FInvalid)
template <typename... Ts>
constexpr bool operator==(const TVariant<Ts...>& LHS, FInvalid)
{
return !LHS.IsValid();
}

View File

@ -24,15 +24,15 @@ NAMESPACE_PRIVATE_BEGIN
template <typename...>
struct TCommonTypeImpl;
// If sizeof...(Types) is zero, there is no member Type
// If sizeof...(Ts) is zero, there is no member Type
template <>
struct TCommonTypeImpl<> { };
// If sizeof...(Types) is one, the member Type names the same Type as TCommonType<T, T> if it exists; otherwise there is no member Type
// If sizeof...(Ts) is one, the member Type names the same Type as TCommonType<T, T> if it exists; otherwise there is no member Type
template <typename T>
struct TCommonTypeImpl<T> : TCommonTypeImpl<T, T> { };
// If sizeof...(Types) is two
// If sizeof...(Ts) is two
// If applying TDecay to at least one of T and U produces a different Type, the member Type names the same Type as TCommonType<TDecay<T>, TDecay<U>>, if it exists; if not, there is no member Type
template <typename T, typename U> concept CDecayed = CSameAs<T, TDecay<T>> && CSameAs<U, TDecay<U>>;
@ -65,11 +65,11 @@ struct TCommonTypeImpl<T, U> { using Type = TDecay<decltype(false ? DeclVal<cons
// Otherwise, there is no member Type
// If sizeof...(Types) is greater than two
// If sizeof...(Ts) is greater than two
// If TCommonType<T, U> exists, the member Type denotes TCommonType<TCommonType<T, U>, R...> if such a Type exists
template <typename T, typename U, typename W, typename... Types> requires (requires { typename TCommonTypeImpl<T, U>::Type; })
struct TCommonTypeImpl<T, U, W, Types...> : TCommonTypeImpl<typename TCommonTypeImpl<T, U>::Type, W, Types...> { };
template <typename T, typename U, typename W, typename... Ts> requires (requires { typename TCommonTypeImpl<T, U>::Type; })
struct TCommonTypeImpl<T, U, W, Ts...> : TCommonTypeImpl<typename TCommonTypeImpl<T, U>::Type, W, Ts...> { };
// In all other cases, there is no member Type
template <typename...>
@ -99,7 +99,7 @@ struct TCommonReferenceImpl<> { };
template <typename T>
struct TCommonReferenceImpl<T> { using Type = T; };
// If sizeof...(Types) is two
// If sizeof...(Ts) is two
// If T and U are both reference types, and the simple common reference Type S of T and U exists, then the member Type Type names S
template <typename T, typename U> concept CSimpleCommonReference = requires { typename TSimpleCommonReferenceImpl<T, U>::Type; };
@ -137,11 +137,11 @@ struct TCommonReferenceImpl<T, U> : TCommonTypeImpl<T, U> { };
// Otherwise, there is no member Type.
// If sizeof...(Types) is greater than two
// If sizeof...(Ts) is greater than two
// If TCommonReference<T, U> exists, the member Type denotes TCommonReference<TCommonReference<T, U>, R...> if such a Type exists
template <typename T, typename U, typename W, typename... Types> requires (requires { typename TCommonReferenceImpl<T, U>::Type; })
struct TCommonReferenceImpl<T, U, W, Types...> : TCommonReferenceImpl<typename TCommonReferenceImpl<T, U>::Type, W, Types...> { };
template <typename T, typename U, typename W, typename... Ts> requires (requires { typename TCommonReferenceImpl<T, U>::Type; })
struct TCommonReferenceImpl<T, U, W, Ts...> : TCommonReferenceImpl<typename TCommonReferenceImpl<T, U>::Type, W, Ts...> { };
// In all other cases, there is no member Type.
template <typename...>
@ -172,19 +172,19 @@ struct TSimpleCommonReferenceImpl { };
NAMESPACE_PRIVATE_END
template <typename... Types> using TCommonType = typename NAMESPACE_PRIVATE::TCommonTypeImpl<Types...>::Type;
template <typename... Types> using TCommonReference = typename NAMESPACE_PRIVATE::TCommonReferenceImpl<Types...>::Type;
template <typename... Ts> using TCommonType = typename NAMESPACE_PRIVATE::TCommonTypeImpl<Ts...>::Type;
template <typename... Ts> using TCommonReference = typename NAMESPACE_PRIVATE::TCommonReferenceImpl<Ts...>::Type;
template <typename... Types>
template <typename... Ts>
concept CCommonReference =
requires { typename TCommonReference<Types...>; }
&& (true && ... && CConvertibleTo<Types, TCommonReference<Types...>>);
requires { typename TCommonReference<Ts...>; }
&& (true && ... && CConvertibleTo<Ts, TCommonReference<Ts...>>);
template <typename... Types>
template <typename... Ts>
concept CCommonType =
requires { typename TCommonType<Types...>; }
&& (true && ... && CConstructibleFrom<TCommonReference<Types...>, Types&&>)
&& CCommonReference<const Types&...> && CCommonReference<TCommonType<Types...>&, TCommonReference<const Types&...>>;
requires { typename TCommonType<Ts...>; }
&& (true && ... && CConstructibleFrom<TCommonReference<Ts...>, Ts&&>)
&& CCommonReference<const Ts&...> && CCommonReference<TCommonType<Ts...>&, TCommonReference<const Ts&...>>;
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)

View File

@ -14,11 +14,11 @@ template <typename R, typename F, typename... Args> concept CInvocableResult = N
template <typename F, typename... Args> using TInvokeResult = NAMESPACE_STD::invoke_result_t<F, Args...>; // FIXME: The result for char(&())[2] is wrong on MSVC
template <typename F, typename... Types>
concept CRegularInvocable = CInvocable<F, Types...>;
template <typename F, typename... Ts>
concept CRegularInvocable = CInvocable<F, Ts...>;
template <typename F, typename... Types>
concept CPredicate = CRegularInvocable<F, Types...> && CBooleanTestable<TInvokeResult<F, Types...>>;
template <typename F, typename... Ts>
concept CPredicate = CRegularInvocable<F, Ts...> && CBooleanTestable<TInvokeResult<F, Ts...>>;
template <typename R, typename T, typename U>
concept CRelation =

View File

@ -52,12 +52,12 @@ template <typename T> using TMakeSigned = NAMESPACE_STD::make_signed_t<T>;
template <typename T> using TMakeUnsigned = NAMESPACE_STD::make_unsigned_t<T>;
template <size_t Size, size_t Align = 16> class TAlignedStorage { struct alignas(Align) { uint8 Pad[Size]; } Padding; };
template <size_t Size, typename... Types> using TAlignedUnion = TAlignedStorage<NAMESPACE_PRIVATE::TMaximum<Size, sizeof(Types)...>::Value, NAMESPACE_PRIVATE::TMaximum<alignof(Types)...>::Value>;
template <size_t Size, typename... Ts> using TAlignedUnion = TAlignedStorage<NAMESPACE_PRIVATE::TMaximum<Size, sizeof(Ts)...>::Value, NAMESPACE_PRIVATE::TMaximum<alignof(Ts)...>::Value>;
template <typename T> using TDecay = NAMESPACE_STD::decay_t<T>;
template <bool B, typename T = void> using TEnableIf = NAMESPACE_STD::enable_if_t<B, T>;
template <bool B, typename T, typename F> using TConditional = NAMESPACE_STD::conditional_t<B, T, F>;
template <typename T> using TUnderlyingType = NAMESPACE_STD::underlying_type_t<T>;
template <typename... Types> using TVoid = void;
template <typename... Ts> using TVoid = void;
template <typename T> using TIdentity = T;
NAMESPACE_MODULE_END(Utility)