fix(typetraits): optimize TIsScopedEnum implementation and flag TInvokeResult errors
This commit is contained in:
parent
73bb0e9cfa
commit
fc38e3d913
@ -437,6 +437,7 @@ void TestTypeTraits()
|
|||||||
|
|
||||||
always_check((TypeTraits::TIsSame<int32, TypeTraits::TInvokeResult<int32()>::Type>::Value));
|
always_check((TypeTraits::TIsSame<int32, TypeTraits::TInvokeResult<int32()>::Type>::Value));
|
||||||
always_check((TypeTraits::TIsSame<int32, TypeTraits::TInvokeResult<int32(int32), int32>::Type>::Value));
|
always_check((TypeTraits::TIsSame<int32, TypeTraits::TInvokeResult<int32(int32), int32>::Type>::Value));
|
||||||
|
// always_check((TypeTraits::TIsSame<char(&)[2], TypeTraits::TInvokeResult<char(&())[2]>::Type>::Value));
|
||||||
|
|
||||||
always_check((TypeTraits::TIsSame<void, TypeTraits::TVoid<int32>::Type>::Value));
|
always_check((TypeTraits::TIsSame<void, TypeTraits::TVoid<int32>::Type>::Value));
|
||||||
always_check((TypeTraits::TIsSame<void, TypeTraits::TVoid<int32, int64>::Type>::Value));
|
always_check((TypeTraits::TIsSame<void, TypeTraits::TVoid<int32, int64>::Type>::Value));
|
||||||
|
@ -53,7 +53,7 @@ template <bool B, typename T = void> struct TEnableIf { using Type =
|
|||||||
template <bool B, typename T, typename F> struct TConditional { using Type = NAMESPACE_STD::conditional_t<B, T, F>; };
|
template <bool B, typename T, typename F> struct TConditional { using Type = NAMESPACE_STD::conditional_t<B, T, F>; };
|
||||||
template <typename... Types> struct TCommonType { using Type = NAMESPACE_STD::common_type_t<Types...>; };
|
template <typename... Types> struct TCommonType { using Type = NAMESPACE_STD::common_type_t<Types...>; };
|
||||||
template <typename T> struct TUnderlyingType { using Type = NAMESPACE_STD::underlying_type_t<T>; };
|
template <typename T> struct TUnderlyingType { using Type = NAMESPACE_STD::underlying_type_t<T>; };
|
||||||
template <typename F, typename... Args> struct TInvokeResult { using Type = NAMESPACE_STD::invoke_result_t<F, Args...>; };
|
template <typename F, typename... Args> struct TInvokeResult { using Type = NAMESPACE_STD::invoke_result_t<F, Args...>; }; // FIXME: The result for char(&())[2] is wrong on MSVC
|
||||||
template <typename... Types> struct TVoid { using Type = void; };
|
template <typename... Types> struct TVoid { using Type = void; };
|
||||||
|
|
||||||
NAMESPACE_END(TypeTraits)
|
NAMESPACE_END(TypeTraits)
|
||||||
|
@ -28,8 +28,8 @@ template <typename T> struct TIsUnboundedArray : TBoolConstant<NAM
|
|||||||
|
|
||||||
NAMESPACE_PRIVATE_BEGIN
|
NAMESPACE_PRIVATE_BEGIN
|
||||||
|
|
||||||
char(&Resolve(int64))[2];
|
uint8(&Resolve(int64))[2];
|
||||||
char Resolve(...);
|
uint8 Resolve(...);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TIsEnumConvertibleToInt : TBoolConstant<sizeof(Resolve(T())) - 1> { };
|
struct TIsEnumConvertibleToInt : TBoolConstant<sizeof(Resolve(T())) - 1> { };
|
||||||
@ -37,7 +37,7 @@ struct TIsEnumConvertibleToInt : TBoolConstant<sizeof(Resolve(T())) - 1> { };
|
|||||||
NAMESPACE_PRIVATE_END
|
NAMESPACE_PRIVATE_END
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TIsScopedEnum : TBoolConstant<TAnd<TIsEnum<T>, TNot<NAMESPACE_PRIVATE::TIsEnumConvertibleToInt<T>>>::Value> { };
|
struct TIsScopedEnum : TAnd<TIsEnum<T>, TNot<NAMESPACE_PRIVATE::TIsEnumConvertibleToInt<T>>> { };
|
||||||
|
|
||||||
NAMESPACE_END(TypeTraits)
|
NAMESPACE_END(TypeTraits)
|
||||||
NAMESPACE_MODULE_END(Utility)
|
NAMESPACE_MODULE_END(Utility)
|
||||||
|
Loading…
Reference in New Issue
Block a user