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

This commit is contained in:
2022-05-29 23:18:20 +08:00
parent c6620da1dd
commit 8b902d15a4
8 changed files with 202 additions and 31 deletions

View File

@ -580,6 +580,19 @@ constexpr void VisitTuple(F&& Func, FirstTupleType&& FirstTuple, TupleTypes&&...
NAMESPACE_PRIVATE::TTupleVisitImpl<TMakeIndexSequence<TTupleElementSize<FirstTupleType>::Value>>::F(Forward<F>(Func), Forward<FirstTupleType>(FirstTuple), Forward<TupleTypes>(Tuples)...);
}
template <typename... Ts, typename... Us> requires requires { typename TTuple<TCommonType<Ts, Us>...>; }
struct TBasicCommonType<TTuple<Ts...>, TTuple<Us...>>
{
using Type = TTuple<TCommonType<Ts, Us>...>;
};
template <typename... Ts, typename... Us, template<typename> typename TQualifiers, template<typename> typename UQualifiers>
requires requires { typename TTuple<TCommonReference<TQualifiers<Ts>, UQualifiers<Us>>...>; }
struct TBasicCommonReference<TTuple<Ts...>, TTuple<Us...>, TQualifiers, UQualifiers>
{
using Type = TTuple<TCommonReference<TQualifiers<Ts>, UQualifiers<Us>>...>;
};
NAMESPACE_MODULE_END(Utility)
NAMESPACE_MODULE_END(Redcraft)
NAMESPACE_REDCRAFT_END

View File

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

View File

@ -236,7 +236,7 @@ struct TVariant
{
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
using ReturnType = typename TCommonType<TInvokeResult<F, Types>...>::Type;
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
using FInvokeImpl = ReturnType(*)(F&&, void*);
static constexpr FInvokeImpl InvokeImpl[] = { [](F&& Func, void* This) -> ReturnType { return InvokeResult<ReturnType>(Forward<F>(Func), *reinterpret_cast<Types*>(This)); }... };
@ -249,7 +249,7 @@ struct TVariant
{
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
using ReturnType = typename TCommonType<TInvokeResult<F, Types>...>::Type;
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
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))); }... };
@ -262,7 +262,7 @@ struct TVariant
{
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
using ReturnType = typename TCommonType<TInvokeResult<F, Types>...>::Type;
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
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)); }... };
@ -275,7 +275,7 @@ struct TVariant
{
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
using ReturnType = typename TCommonType<TInvokeResult<F, Types>...>::Type;
using ReturnType = TCommonType<TInvokeResult<F, Types>...>;
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))); }... };