refactor(typetraits): replaces template class type traits with alias template for TypeTraits/CopyQualifiers.h
This commit is contained in:
parent
4205a23310
commit
c6620da1dd
@ -480,81 +480,81 @@ void TestTypeTraits()
|
||||
|
||||
// CopyQualifiers.h
|
||||
|
||||
always_check((CSameAs< int32, TCopyConst< int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const volatile int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyConst< int32, const int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const int32, const int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const volatile int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyConst< int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyConst<const int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyConst<const volatile int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs< int32, TCopyConst< int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const volatile int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyConst< int32, const int32>>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const int32, const int32>>));
|
||||
always_check((CSameAs<const int32, TCopyConst<const volatile int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyConst< int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyConst<const int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyConst<const volatile int32, const volatile int32>>));
|
||||
|
||||
always_check((CSameAs< int32, TCopyVolatile< int32, int32>::Type>));
|
||||
always_check((CSameAs< int32, TCopyVolatile<const int32, int32>::Type>));
|
||||
always_check((CSameAs< volatile int32, TCopyVolatile<const volatile int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyVolatile< int32, const int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyVolatile<const int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile<const volatile int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile< int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile<const int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile<const volatile int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs< int32, TCopyVolatile< int32, int32>>));
|
||||
always_check((CSameAs< int32, TCopyVolatile<const int32, int32>>));
|
||||
always_check((CSameAs< volatile int32, TCopyVolatile<const volatile int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyVolatile< int32, const int32>>));
|
||||
always_check((CSameAs<const int32, TCopyVolatile<const int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile<const volatile int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile< int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile<const int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyVolatile<const volatile int32, const volatile int32>>));
|
||||
|
||||
always_check((CSameAs< int32, TCopyCV< int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCV<const int32, int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const volatile int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCV< int32, const int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCV<const int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const volatile int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV< int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const volatile int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs< int32, TCopyCV< int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCV<const int32, int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const volatile int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCV< int32, const int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCV<const int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const volatile int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV< int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCV<const volatile int32, const volatile int32>>));
|
||||
|
||||
always_check((CSameAs<int32, TCopyReference<int32, int32 >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32, int32& >::Type>));
|
||||
always_check((CSameAs<int32&&, TCopyReference<int32, int32&&>::Type>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&, int32 >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&, int32& >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&, int32&&>::Type>));
|
||||
always_check((CSameAs<int32&&, TCopyReference<int32&&, int32 >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&&, int32& >::Type>));
|
||||
always_check((CSameAs<int32&&, TCopyReference<int32&&, int32&&>::Type>));
|
||||
always_check((CSameAs<int32, TCopyReference<int32, int32 >>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32, int32& >>));
|
||||
always_check((CSameAs<int32&&, TCopyReference<int32, int32&&>>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&, int32 >>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&, int32& >>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&, int32&&>>));
|
||||
always_check((CSameAs<int32&&, TCopyReference<int32&&, int32 >>));
|
||||
always_check((CSameAs<int32&, TCopyReference<int32&&, int32& >>));
|
||||
always_check((CSameAs<int32&&, TCopyReference<int32&&, int32&&>>));
|
||||
|
||||
always_check((CSameAs< int32, TCopyCVRef< int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef< int32, const int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, const int32>::Type>));
|
||||
always_check((CSameAs< volatile int32, TCopyCVRef< volatile int32, int32>::Type>));
|
||||
always_check((CSameAs< volatile int32, TCopyCVRef< int32, volatile int32>::Type>));
|
||||
always_check((CSameAs< volatile int32, TCopyCVRef< volatile int32, volatile int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const volatile int32, int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef< int32, const int32>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const volatile int32, const int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef< int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const volatile int32, const volatile int32>::Type>));
|
||||
always_check((CSameAs< int32, TCopyCVRef< int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef< int32, const int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, const int32>>));
|
||||
always_check((CSameAs< volatile int32, TCopyCVRef< volatile int32, int32>>));
|
||||
always_check((CSameAs< volatile int32, TCopyCVRef< int32, volatile int32>>));
|
||||
always_check((CSameAs< volatile int32, TCopyCVRef< volatile int32, volatile int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const volatile int32, int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef< int32, const int32>>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const volatile int32, const int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef< int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const int32, const volatile int32>>));
|
||||
always_check((CSameAs<const volatile int32, TCopyCVRef<const volatile int32, const volatile int32>>));
|
||||
|
||||
always_check((CSameAs<int32, TCopyCVRef<int32, int32 >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32, int32& >::Type>));
|
||||
always_check((CSameAs<int32&&, TCopyCVRef<int32, int32&&>::Type>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&, int32 >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&, int32& >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&, int32&&>::Type>));
|
||||
always_check((CSameAs<int32&&, TCopyCVRef<int32&&, int32 >::Type>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&&, int32& >::Type>));
|
||||
always_check((CSameAs<int32&&, TCopyCVRef<int32&&, int32&&>::Type>));
|
||||
always_check((CSameAs<int32, TCopyCVRef<int32, int32 >>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32, int32& >>));
|
||||
always_check((CSameAs<int32&&, TCopyCVRef<int32, int32&&>>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&, int32 >>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&, int32& >>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&, int32&&>>));
|
||||
always_check((CSameAs<int32&&, TCopyCVRef<int32&&, int32 >>));
|
||||
always_check((CSameAs<int32&, TCopyCVRef<int32&&, int32& >>));
|
||||
always_check((CSameAs<int32&&, TCopyCVRef<int32&&, int32&&>>));
|
||||
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, int32 >::Type>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef< int32, const int32& >::Type>));
|
||||
always_check((CSameAs<const volatile int32&&, TCopyCVRef<const volatile int32, const int32&&>::Type>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef<const int32&, int32 >::Type>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef<const int32&, const int32& >::Type>));
|
||||
always_check((CSameAs<const volatile int32&, TCopyCVRef< volatile int32&, const int32&&>::Type>));
|
||||
always_check((CSameAs<const int32&&, TCopyCVRef<const int32&&, int32 >::Type>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef<const int32&&, const int32& >::Type>));
|
||||
always_check((CSameAs<const volatile int32&&, TCopyCVRef<const volatile int32&&, const int32&&>::Type>));
|
||||
always_check((CSameAs<const int32, TCopyCVRef<const int32, int32 >>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef< int32, const int32& >>));
|
||||
always_check((CSameAs<const volatile int32&&, TCopyCVRef<const volatile int32, const int32&&>>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef<const int32&, int32 >>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef<const int32&, const int32& >>));
|
||||
always_check((CSameAs<const volatile int32&, TCopyCVRef< volatile int32&, const int32&&>>));
|
||||
always_check((CSameAs<const int32&&, TCopyCVRef<const int32&&, int32 >>));
|
||||
always_check((CSameAs<const int32&, TCopyCVRef<const int32&&, const int32& >>));
|
||||
always_check((CSameAs<const volatile int32&&, TCopyCVRef<const volatile int32&&, const int32&&>>));
|
||||
|
||||
// BooleanTestable.h
|
||||
|
||||
|
@ -146,8 +146,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
using StorageType = TConditional<bIsRef, typename TCopyConst<CVRef, void>::Type*, TAny<InlineSize, 1>>;
|
||||
using StorageRef = TConditional<bIsRef, typename TCopyConst<CVRef, void>::Type*, typename TCopyCVRef<CVRef, StorageType>::Type&>;
|
||||
using StorageType = TConditional<bIsRef, TCopyConst<CVRef, void>*, TAny<InlineSize, 1>>;
|
||||
using StorageRef = TConditional<bIsRef, TCopyConst<CVRef, void>*, TCopyCVRef<CVRef, StorageType>&>;
|
||||
|
||||
using CallFunc = ResultType(*)(StorageRef, Types&&...);
|
||||
|
||||
@ -171,7 +171,7 @@ protected:
|
||||
template <typename DecayedType, typename... ArgTypes>
|
||||
FORCEINLINE void EmplaceImpl(ArgTypes&&... Args)
|
||||
{
|
||||
using CallableType = typename TCopyConst<TRemoveReference<CVRef>, DecayedType>::Type;
|
||||
using CallableType = TCopyConst<TRemoveReference<CVRef>, DecayedType>;
|
||||
|
||||
if constexpr (bIsRef) Storage = ((reinterpret_cast<StorageType>(AddressOf(Args))), ...);
|
||||
else Storage.template Emplace<DecayedType>(Forward<ArgTypes>(Args)...);
|
||||
@ -180,8 +180,8 @@ protected:
|
||||
{
|
||||
using InvokeType = TConditional<
|
||||
CReference<CVRef>,
|
||||
typename TCopyCVRef<CVRef, CallableType>::Type,
|
||||
typename TCopyCVRef<CVRef, CallableType>::Type&
|
||||
TCopyCVRef<CVRef, CallableType>,
|
||||
TCopyCVRef<CVRef, CallableType>&
|
||||
>;
|
||||
|
||||
const auto GetFunc = [&Storage]() -> InvokeType
|
||||
|
@ -405,7 +405,7 @@ template <typename TupleType> requires CTTuple<TRemoveCVRef<TupleType>>
|
||||
struct TTupleElementSize : TConstant<size_t, TRemoveCVRef<TupleType>::ElementSize> { };
|
||||
|
||||
template <size_t I, typename TupleType> requires CTTuple<TRemoveCVRef<TupleType>>
|
||||
struct TTupleElementType { using Type = typename TCopyCVRef<TRemoveReference<TupleType>, typename TRemoveCVRef<TupleType>::template TElementType<I>::Type>::Type; };
|
||||
struct TTupleElementType { using Type = TCopyCVRef<TRemoveReference<TupleType>, typename TRemoveCVRef<TupleType>::template TElementType<I>::Type>; };
|
||||
|
||||
template <typename T, typename TupleType> requires CTTuple<TRemoveCVRef<TupleType>>
|
||||
struct TTupleElementIndex : TupleType::template TElementIndex<T> { };
|
||||
|
@ -422,7 +422,7 @@ template <typename VariantType> requires CTVariant<TRemoveCVRef<VariantType>>
|
||||
struct TVariantAlternativeSize : TConstant<size_t, VariantType::AlternativeSize> { };
|
||||
|
||||
template <size_t I, typename VariantType> requires CTVariant<TRemoveCVRef<VariantType>>
|
||||
struct TVariantAlternativeType { using Type = typename TCopyCV<TRemoveReference<VariantType>, typename TRemoveCVRef<VariantType>::template TAlternativeType<I>::Type>::Type; };
|
||||
struct TVariantAlternativeType { using Type = TCopyCV<TRemoveReference<VariantType>, typename TRemoveCVRef<VariantType>::template TAlternativeType<I>::Type>; };
|
||||
|
||||
template <typename T, typename VariantType> requires CTVariant<TRemoveCVRef<VariantType>>
|
||||
struct TVariantAlternativeIndex : VariantType::template TAlternativeIndex<T> { };
|
||||
|
@ -9,27 +9,37 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
template <typename From, typename To> struct TCopyConst { using Type = To; };
|
||||
template <typename From, typename To> struct TCopyConst<const From, To> { using Type = const To; };
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
|
||||
template <typename From, typename To> struct TCopyVolatile { using Type = To; };
|
||||
template <typename From, typename To> struct TCopyVolatile<volatile From, To> { using Type = volatile To; };
|
||||
template <typename From, typename To> struct TCopyConstImpl { using Type = To; };
|
||||
template <typename From, typename To> struct TCopyConstImpl<const From, To> { using Type = const To; };
|
||||
|
||||
template <typename From, typename To> struct TCopyCV { using Type = typename TCopyConst<From, typename TCopyVolatile<From, To>::Type>::Type; };
|
||||
template <typename From, typename To> struct TCopyVolatileImpl { using Type = To; };
|
||||
template <typename From, typename To> struct TCopyVolatileImpl<volatile From, To> { using Type = volatile To; };
|
||||
|
||||
template <typename From, typename To> struct TCopyReference { using Type = To; };
|
||||
template <typename From, typename To> struct TCopyReference<From&, To > { using Type = To&; };
|
||||
template <typename From, typename To> struct TCopyReference<From&&, To > { using Type = To&&; };
|
||||
template <typename From, typename To> struct TCopyCVImpl { using Type = typename TCopyConstImpl<From, typename TCopyVolatileImpl<From, To>::Type>::Type; };
|
||||
|
||||
template <typename From, typename To> struct TCopyCVRef { using Type = typename TCopyCV<From, To>::Type; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From, To& > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From, To&&> { using Type = typename TCopyCV<From, To>::Type&&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From&, To > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From&, To& > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From&, To&&> { using Type = typename TCopyCV<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From&&, To > { using Type = typename TCopyCV<From, To>::Type&&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From&&, To& > { using Type = typename TCopyCV<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRef<From&&, To&&> { using Type = typename TCopyCV<From, To>::Type&&; };
|
||||
template <typename From, typename To> struct TCopyReferenceImpl { using Type = To; };
|
||||
template <typename From, typename To> struct TCopyReferenceImpl<From&, To> { using Type = To&; };
|
||||
template <typename From, typename To> struct TCopyReferenceImpl<From&&, To> { using Type = To&&; };
|
||||
|
||||
template <typename From, typename To> struct TCopyCVRefImpl { using Type = typename TCopyCVImpl<From, To>::Type; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From, To& > { using Type = typename TCopyCVImpl<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From, To&&> { using Type = typename TCopyCVImpl<From, To>::Type&&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From&, To > { using Type = typename TCopyCVImpl<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From&, To& > { using Type = typename TCopyCVImpl<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From&, To&&> { using Type = typename TCopyCVImpl<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From&&, To > { using Type = typename TCopyCVImpl<From, To>::Type&&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From&&, To& > { using Type = typename TCopyCVImpl<From, To>::Type&; };
|
||||
template <typename From, typename To> struct TCopyCVRefImpl<From&&, To&&> { using Type = typename TCopyCVImpl<From, To>::Type&&; };
|
||||
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
template <typename From, typename To> using TCopyConst = typename NAMESPACE_PRIVATE::TCopyConstImpl<From, To>::Type;
|
||||
template <typename From, typename To> using TCopyVolatile = typename NAMESPACE_PRIVATE::TCopyVolatileImpl<From, To>::Type;
|
||||
template <typename From, typename To> using TCopyCV = typename NAMESPACE_PRIVATE::TCopyCVImpl<From, To>::Type;
|
||||
template <typename From, typename To> using TCopyReference = typename NAMESPACE_PRIVATE::TCopyReferenceImpl<From, To>::Type;
|
||||
template <typename From, typename To> using TCopyCVRef = typename NAMESPACE_PRIVATE::TCopyCVRefImpl<From, To>::Type;
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
|
Loading…
Reference in New Issue
Block a user