fix(typetraits): fix implementation of TIsScopedEnum TIsSwappable and TIsBitwiseConstructible
This commit is contained in:
parent
d634fc3cf8
commit
38902eb779
@ -10,7 +10,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
|
|
||||||
NAMESPACE_BEGIN(Testing)
|
NAMESPACE_BEGIN(Testing)
|
||||||
|
|
||||||
// Warning: The test here is not a complete test, it is only used to determine whether the environment supports the concepts
|
// WARNING: The test here is not a complete test, it is only used to determine whether the environment supports the concepts
|
||||||
|
|
||||||
NAMESPACE_UNNAMED_BEGIN
|
NAMESPACE_UNNAMED_BEGIN
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
|
|
||||||
NAMESPACE_BEGIN(Testing)
|
NAMESPACE_BEGIN(Testing)
|
||||||
|
|
||||||
// Warning: The test here is not a complete test, it is only used to determine whether the environment supports the traits
|
// WARNING: The test here is not a complete test, it is only used to determine whether the environment supports the traits
|
||||||
|
|
||||||
NAMESPACE_UNNAMED_BEGIN
|
NAMESPACE_UNNAMED_BEGIN
|
||||||
|
|
||||||
|
@ -35,11 +35,9 @@ template <typename T, typename U> struct TIsBitwiseConstructible<const volatile
|
|||||||
template <typename T, typename U> struct TIsBitwiseConstructible<const volatile T, volatile U> : TIsBitwiseConstructible<T, U> { };
|
template <typename T, typename U> struct TIsBitwiseConstructible<const volatile T, volatile U> : TIsBitwiseConstructible<T, U> { };
|
||||||
template <typename T, typename U> struct TIsBitwiseConstructible<const volatile T, const volatile U> : TIsBitwiseConstructible<T, U> { };
|
template <typename T, typename U> struct TIsBitwiseConstructible<const volatile T, const volatile U> : TIsBitwiseConstructible<T, U> { };
|
||||||
|
|
||||||
template <typename T> struct TIsBitwiseConstructible<T, T> : TIsTriviallyCopyConstructible<T> { };
|
template <typename T, typename U> struct TIsBitwiseConstructible<T*, U*> : TIsConvertible<U*, T*> { };
|
||||||
|
|
||||||
template <typename T, typename U> struct TIsBitwiseConstructible<T*, U*> : TBoolConstant<TIsSame<typename TRemoveCV<T>::Type, typename TRemoveCV<U>::Type>::Value> { };
|
template <typename T, typename U> struct TIsBitwiseConstructible : TBoolConstant<TIsSame<T, U>::Value ? TIsTriviallyCopyConstructible<T>::Value : false> { };
|
||||||
|
|
||||||
template <typename T, typename U> struct TIsBitwiseConstructible : FFalse { };
|
|
||||||
|
|
||||||
template <> struct TIsBitwiseConstructible<uint8, int8> : FTrue { };
|
template <> struct TIsBitwiseConstructible<uint8, int8> : FTrue { };
|
||||||
template <> struct TIsBitwiseConstructible< int8, uint8> : FTrue { };
|
template <> struct TIsBitwiseConstructible< int8, uint8> : FTrue { };
|
||||||
@ -50,6 +48,11 @@ template <> struct TIsBitwiseConstructible< int32, uint32> : FTrue { };
|
|||||||
template <> struct TIsBitwiseConstructible<uint64, int64> : FTrue { };
|
template <> struct TIsBitwiseConstructible<uint64, int64> : FTrue { };
|
||||||
template <> struct TIsBitwiseConstructible< int64, uint64> : FTrue { };
|
template <> struct TIsBitwiseConstructible< int64, uint64> : FTrue { };
|
||||||
|
|
||||||
|
template <typename T> struct TIsBitwiseConstructible<T*, intptr> : FTrue { };
|
||||||
|
template <typename T> struct TIsBitwiseConstructible<T*, uintptr> : FTrue { };
|
||||||
|
template <typename T> struct TIsBitwiseConstructible< intptr, T*> : FTrue { };
|
||||||
|
template <typename T> struct TIsBitwiseConstructible<uintptr, T*> : FTrue { };
|
||||||
|
|
||||||
// It is usually only necessary to specialize TIsBitwiseConstructible and not recommended to specialize TIsBitwiseRelocatable.
|
// It is usually only necessary to specialize TIsBitwiseConstructible and not recommended to specialize TIsBitwiseRelocatable.
|
||||||
template <typename T, typename U> struct TIsBitwiseRelocatable;
|
template <typename T, typename U> struct TIsBitwiseRelocatable;
|
||||||
|
|
||||||
@ -69,7 +72,7 @@ template <typename T, typename U> struct TIsBitwiseRelocatable<const volatile T,
|
|||||||
template <typename T, typename U> struct TIsBitwiseRelocatable<const volatile T, volatile U> : TIsBitwiseRelocatable<T, U> { };
|
template <typename T, typename U> struct TIsBitwiseRelocatable<const volatile T, volatile U> : TIsBitwiseRelocatable<T, U> { };
|
||||||
template <typename T, typename U> struct TIsBitwiseRelocatable<const volatile T, const volatile U> : TIsBitwiseRelocatable<T, U> { };
|
template <typename T, typename U> struct TIsBitwiseRelocatable<const volatile T, const volatile U> : TIsBitwiseRelocatable<T, U> { };
|
||||||
|
|
||||||
template <typename T> struct TIsBitwiseRelocatable<T, T> : FTrue { };
|
template <typename T> struct TIsBitwiseRelocatable<T, T> : TBoolConstant<!TIsVoid<T>::Value> { };
|
||||||
|
|
||||||
template <typename T, typename U> struct TIsBitwiseRelocatable : TBoolConstant<TIsBitwiseConstructible<T, U>::Value && TIsTriviallyDestructible<U>::Value> { };
|
template <typename T, typename U> struct TIsBitwiseRelocatable : TBoolConstant<TIsBitwiseConstructible<T, U>::Value && TIsTriviallyDestructible<U>::Value> { };
|
||||||
|
|
||||||
|
@ -10,17 +10,22 @@ NAMESPACE_MODULE_BEGIN(Utility)
|
|||||||
|
|
||||||
NAMESPACE_PRIVATE_BEGIN
|
NAMESPACE_PRIVATE_BEGIN
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept CSwappable = requires(T & A, T & B) { Swap(A, B); };
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
concept CSwappableWith =
|
concept CSwappableWith =
|
||||||
requires(T&& A, U&& B)
|
requires(T&& A, U&& B)
|
||||||
{
|
{
|
||||||
Swap(A, B);
|
Swap(Forward<T>(A), Forward<T>(A));
|
||||||
Swap(B, A);
|
Swap(Forward<U>(B), Forward<U>(B));
|
||||||
|
Swap(Forward<T>(A), Forward<U>(B));
|
||||||
|
Swap(Forward<U>(B), Forward<T>(A));
|
||||||
};
|
};
|
||||||
|
|
||||||
NAMESPACE_PRIVATE_END
|
NAMESPACE_PRIVATE_END
|
||||||
|
|
||||||
template <typename T> struct TIsSwappable : TBoolConstant<NAMESPACE_PRIVATE::CSwappableWith<T&, T&>> { };
|
template <typename T> struct TIsSwappable : TBoolConstant<NAMESPACE_PRIVATE::CSwappable<T>> { };
|
||||||
template <typename T, typename U> struct TIsSwappableWith : TBoolConstant<NAMESPACE_PRIVATE::CSwappableWith<T, U>> { };
|
template <typename T, typename U> struct TIsSwappableWith : TBoolConstant<NAMESPACE_PRIVATE::CSwappableWith<T, U>> { };
|
||||||
|
|
||||||
//template <typename T> struct TIsNothrowSwappable;
|
//template <typename T> struct TIsNothrowSwappable;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "CoreTypes.h"
|
#include "CoreTypes.h"
|
||||||
#include "TypeTraits/HelperClasses.h"
|
#include "TypeTraits/HelperClasses.h"
|
||||||
|
#include "TypeTraits/Miscellaneous.h"
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -25,18 +26,8 @@ template <typename T> struct TIsUnsigned : TBoolConstant<NAM
|
|||||||
template <typename T> struct TIsBoundedArray : TBoolConstant<NAMESPACE_STD::is_bounded_array_v<T>> { };
|
template <typename T> struct TIsBoundedArray : TBoolConstant<NAMESPACE_STD::is_bounded_array_v<T>> { };
|
||||||
template <typename T> struct TIsUnboundedArray : TBoolConstant<NAMESPACE_STD::is_unbounded_array_v<T>> { };
|
template <typename T> struct TIsUnboundedArray : TBoolConstant<NAMESPACE_STD::is_unbounded_array_v<T>> { };
|
||||||
|
|
||||||
NAMESPACE_PRIVATE_BEGIN
|
|
||||||
|
|
||||||
uint8(&Resolve(int64))[2];
|
|
||||||
uint8 Resolve(...);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TIsEnumConvertibleToInt : TBoolConstant<sizeof(Resolve(T())) - 1> { };
|
struct TIsScopedEnum : TBoolConstant<TIsEnum<T>::Value && !TIsConvertible<T, int64>::Value> { };
|
||||||
|
|
||||||
NAMESPACE_PRIVATE_END
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct TIsScopedEnum : TBoolConstant<TIsEnum<T>::Value && !NAMESPACE_PRIVATE::TIsEnumConvertibleToInt<T>::Value> { };
|
|
||||||
|
|
||||||
NAMESPACE_MODULE_END(Utility)
|
NAMESPACE_MODULE_END(Utility)
|
||||||
NAMESPACE_MODULE_END(Redcraft)
|
NAMESPACE_MODULE_END(Redcraft)
|
||||||
|
Loading…
Reference in New Issue
Block a user