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

This commit is contained in:
2022-05-15 23:10:02 +08:00
parent 1dcd3dc3b3
commit 22fe906eda
10 changed files with 59 additions and 73 deletions

View File

@ -42,7 +42,7 @@ NAMESPACE_PRIVATE_BEGIN
template <typename T>
constexpr bool FunctionIsBound(const T& Func)
{
if constexpr (CPointer<T> || TIsMemberPointer<T>::Value || TIsTFunctionRef<T>::Value || TIsTFunction<T>::Value || TIsTUniqueFunction<T>::Value)
if constexpr (CPointer<T> || CMemberPointer<T> || TIsTFunctionRef<T>::Value || TIsTFunction<T>::Value || TIsTUniqueFunction<T>::Value)
{
return !!Func;
}
@ -171,7 +171,7 @@ protected:
Callable = [](StorageRef Storage, Types&&... Args) -> ResultType
{
using InvokeType = typename TConditional<
TIsReference<CVRef>::Value,
CReference<CVRef>,
typename TCopyCVRef<CVRef, CallableType>::Type,
typename TCopyCVRef<CVRef, CallableType>::Type&
>::Type;

View File

@ -10,7 +10,7 @@ NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility)
template <typename ReferencedType> requires (TIsObject<ReferencedType>::Value || CFunction<ReferencedType>)
template <typename ReferencedType> requires (CObject<ReferencedType> || CFunction<ReferencedType>)
struct TReferenceWrapper
{
public:
@ -61,7 +61,7 @@ private:
ReferencedType* Pointer;
template <typename T> requires (TIsObject<T>::Value || CFunction<T>) friend struct TReferenceWrapper;
template <typename T> requires (CObject<T> || CFunction<T>) friend struct TReferenceWrapper;
// Optimize TOptional with these hacking
constexpr TReferenceWrapper(FInvalid) : Pointer(nullptr) { };

View File

@ -88,13 +88,13 @@ constexpr T Exchange(T& A, U&& B)
template <typename T>
constexpr T&& DeclVal();
template <typename T> requires TIsObject<T>::Value
template <typename T> requires CObject<T>
constexpr T* AddressOf(T& Object)
{
return reinterpret_cast<T*>(&const_cast<char&>(reinterpret_cast<const volatile char&>(Object)));
}
template <typename T> requires (!TIsObject<T>::Value)
template <typename T> requires (!CObject<T>)
constexpr T* AddressOf(T& Object)
{
return &Object;