feat(typetraits): add TypeTraits/CompositeType.h and the corresponding testing
This commit is contained in:
parent
60b4ec6f58
commit
29c01baf63
@ -2,6 +2,7 @@
|
||||
#include "Misc/AssertionMacros.h"
|
||||
#include "TypeTraits/HelperClasses.h"
|
||||
#include "TypeTraits/PrimaryType.h"
|
||||
#include "TypeTraits/CompositeType.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -106,6 +107,46 @@ void TestTypeTraits()
|
||||
|
||||
always_check(!TypeTraits::TIsEnumClass<ETestEnum>::Value);
|
||||
always_check(TypeTraits::TIsEnumClass<ETestEnumClass>::Value);
|
||||
|
||||
// CompositeType.h
|
||||
|
||||
always_check(!TypeTraits::TIsFundamental<FTestStruct>::Value);
|
||||
always_check(TypeTraits::TIsFundamental<int32>::Value);
|
||||
always_check(TypeTraits::TIsFundamental<float>::Value);
|
||||
always_check(!TypeTraits::TIsFundamental<int32*>::Value);
|
||||
always_check(TypeTraits::TIsFundamental<void>::Value);
|
||||
|
||||
always_check(!TypeTraits::TIsArithmetic<FTestStruct>::Value);
|
||||
always_check(TypeTraits::TIsArithmetic<int32>::Value);
|
||||
always_check(TypeTraits::TIsArithmetic<float>::Value);
|
||||
always_check(!TypeTraits::TIsArithmetic<int32*>::Value);
|
||||
always_check(!TypeTraits::TIsArithmetic<void>::Value);
|
||||
|
||||
always_check(!TypeTraits::TIsScalar<FTestStruct>::Value);
|
||||
always_check(TypeTraits::TIsScalar<int32>::Value);
|
||||
always_check(TypeTraits::TIsScalar<float>::Value);
|
||||
always_check(TypeTraits::TIsScalar<int32*>::Value);
|
||||
always_check(!TypeTraits::TIsScalar<void>::Value);
|
||||
|
||||
always_check(TypeTraits::TIsObject<FTestStruct>::Value);
|
||||
always_check(!TypeTraits::TIsObject<FTestStruct&>::Value);
|
||||
always_check(TypeTraits::TIsObject<int32>::Value);
|
||||
always_check(TypeTraits::TIsObject<int32*>::Value);
|
||||
always_check(!TypeTraits::TIsObject<int32&>::Value);
|
||||
|
||||
always_check(TypeTraits::TIsCompound<FTestStruct>::Value);
|
||||
always_check(TypeTraits::TIsCompound<FTestStruct&>::Value);
|
||||
always_check(!TypeTraits::TIsCompound<int32>::Value);
|
||||
always_check(TypeTraits::TIsCompound<int32*>::Value);
|
||||
always_check(TypeTraits::TIsCompound<int32&>::Value);
|
||||
|
||||
always_check(!TypeTraits::TIsReference<int32>::Value);
|
||||
always_check(!TypeTraits::TIsReference<int32*>::Value);
|
||||
always_check(TypeTraits::TIsReference<int32&>::Value);
|
||||
always_check(TypeTraits::TIsReference<int32&&>::Value);
|
||||
|
||||
always_check(!TypeTraits::TIsMemberPointer<FTestStruct>::Value);
|
||||
always_check(TypeTraits::TIsMemberPointer<int32(FTestStruct::*)>::Value);
|
||||
}
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
|
24
Redcraft.Utility/Source/Public/TypeTraits/CompositeType.h
Normal file
24
Redcraft.Utility/Source/Public/TypeTraits/CompositeType.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeTraits/HelperClasses.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
NAMESPACE_BEGIN(TypeTraits)
|
||||
|
||||
template <typename T> struct TIsReference : TBoolConstant<NAMESPACE_STD::is_reference_v<T>> { };
|
||||
template <typename T> struct TIsArithmetic : TBoolConstant<NAMESPACE_STD::is_arithmetic_v<T>> { };
|
||||
template <typename T> struct TIsFundamental : TBoolConstant<NAMESPACE_STD::is_fundamental_v<T>> { };
|
||||
template <typename T> struct TIsObject : TBoolConstant<NAMESPACE_STD::is_object_v<T>> { };
|
||||
template <typename T> struct TIsScalar : TBoolConstant<NAMESPACE_STD::is_scalar_v<T>> { };
|
||||
template <typename T> struct TIsCompound : TBoolConstant<NAMESPACE_STD::is_compound_v<T>> { };
|
||||
template <typename T> struct TIsMemberPointer : TBoolConstant<NAMESPACE_STD::is_member_pointer_v<T>> { };
|
||||
|
||||
NAMESPACE_END(TypeTraits)
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
Loading…
Reference in New Issue
Block a user