From 29c01baf630a19b1c31df3a521b12ec718ec4b04 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Sun, 12 Dec 2021 10:32:22 +0800 Subject: [PATCH] feat(typetraits): add TypeTraits/CompositeType.h and the corresponding testing --- .../Private/Testing/TypeTraitsTesting.cpp | 41 +++++++++++++++++++ .../Source/Public/TypeTraits/CompositeType.h | 24 +++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Redcraft.Utility/Source/Public/TypeTraits/CompositeType.h diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 842d6eb..7a8a059 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -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::Value); always_check(TypeTraits::TIsEnumClass::Value); + + // CompositeType.h + + always_check(!TypeTraits::TIsFundamental::Value); + always_check(TypeTraits::TIsFundamental::Value); + always_check(TypeTraits::TIsFundamental::Value); + always_check(!TypeTraits::TIsFundamental::Value); + always_check(TypeTraits::TIsFundamental::Value); + + always_check(!TypeTraits::TIsArithmetic::Value); + always_check(TypeTraits::TIsArithmetic::Value); + always_check(TypeTraits::TIsArithmetic::Value); + always_check(!TypeTraits::TIsArithmetic::Value); + always_check(!TypeTraits::TIsArithmetic::Value); + + always_check(!TypeTraits::TIsScalar::Value); + always_check(TypeTraits::TIsScalar::Value); + always_check(TypeTraits::TIsScalar::Value); + always_check(TypeTraits::TIsScalar::Value); + always_check(!TypeTraits::TIsScalar::Value); + + always_check(TypeTraits::TIsObject::Value); + always_check(!TypeTraits::TIsObject::Value); + always_check(TypeTraits::TIsObject::Value); + always_check(TypeTraits::TIsObject::Value); + always_check(!TypeTraits::TIsObject::Value); + + always_check(TypeTraits::TIsCompound::Value); + always_check(TypeTraits::TIsCompound::Value); + always_check(!TypeTraits::TIsCompound::Value); + always_check(TypeTraits::TIsCompound::Value); + always_check(TypeTraits::TIsCompound::Value); + + always_check(!TypeTraits::TIsReference::Value); + always_check(!TypeTraits::TIsReference::Value); + always_check(TypeTraits::TIsReference::Value); + always_check(TypeTraits::TIsReference::Value); + + always_check(!TypeTraits::TIsMemberPointer::Value); + always_check(TypeTraits::TIsMemberPointer::Value); } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/CompositeType.h b/Redcraft.Utility/Source/Public/TypeTraits/CompositeType.h new file mode 100644 index 0000000..cf02b3d --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/CompositeType.h @@ -0,0 +1,24 @@ +#pragma once + +#include "CoreTypes.h" +#include "TypeTraits/HelperClasses.h" + +#include + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) +NAMESPACE_BEGIN(TypeTraits) + +template struct TIsReference : TBoolConstant> { }; +template struct TIsArithmetic : TBoolConstant> { }; +template struct TIsFundamental : TBoolConstant> { }; +template struct TIsObject : TBoolConstant> { }; +template struct TIsScalar : TBoolConstant> { }; +template struct TIsCompound : TBoolConstant> { }; +template struct TIsMemberPointer : TBoolConstant> { }; + +NAMESPACE_END(TypeTraits) +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END