diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 7a8a059..a36a1d2 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -3,6 +3,7 @@ #include "TypeTraits/HelperClasses.h" #include "TypeTraits/PrimaryType.h" #include "TypeTraits/CompositeType.h" +#include "TypeTraits/TypeProperties.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) @@ -13,10 +14,16 @@ NAMESPACE_MODULE_BEGIN(Utility) int32 TestObject; void TestFunction() { } -struct FTestStruct { }; +struct FTestStructA { }; +struct FTestStructB { int32 Member; }; +struct FTestStructC { FTestStructC() { } }; +struct FTestStructD { FTestStructD(const FTestStructD&) { } }; +struct FTestStructE { virtual void Member() = 0; }; +struct FTestStructF { int32 MemberA; private: int32 MemberB; }; +struct FTestStructG { char MemberA; float MemberB; short MemberC; int MemberD; }; +struct FTestStructH final : FTestStructE { virtual void Member() override { } }; enum ETestEnum { }; - enum class ETestEnumClass { }; union FTestUnion { }; @@ -81,61 +88,58 @@ void TestTypeTraits() always_check(!TypeTraits::TIsRValueReference::Value); always_check(TypeTraits::TIsRValueReference::Value); - always_check(TypeTraits::TIsMemberObjectPointer::Value); - always_check(!TypeTraits::TIsMemberObjectPointer::Value); + always_check(TypeTraits::TIsMemberObjectPointer::Value); + always_check(!TypeTraits::TIsMemberObjectPointer::Value); - always_check(!TypeTraits::TIsMemberFunctionPointer::Value); - always_check(TypeTraits::TIsMemberFunctionPointer::Value); + always_check(!TypeTraits::TIsMemberFunctionPointer::Value); + always_check(TypeTraits::TIsMemberFunctionPointer::Value); always_check(!TypeTraits::TIsEnum::Value); - always_check(!TypeTraits::TIsEnum::Value); + always_check(!TypeTraits::TIsEnum::Value); always_check(TypeTraits::TIsEnum::Value); always_check(TypeTraits::TIsEnum::Value); always_check(!TypeTraits::TIsUnion::Value); - always_check(!TypeTraits::TIsUnion::Value); + always_check(!TypeTraits::TIsUnion::Value); always_check(TypeTraits::TIsUnion::Value); always_check(!TypeTraits::TIsUnion::Value); - always_check(!TypeTraits::TIsUnion::Value); + always_check(!TypeTraits::TIsUnion::Value); always_check(TypeTraits::TIsUnion::Value); always_check(!TypeTraits::TIsFunction::Value); - always_check(!TypeTraits::TIsFunction::Value); + always_check(!TypeTraits::TIsFunction::Value); always_check(!TypeTraits::TIsFunction::Value); always_check(TypeTraits::TIsFunction::Value); - 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::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::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::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::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::TIsCompound::Value); always_check(TypeTraits::TIsCompound::Value); @@ -145,8 +149,72 @@ void TestTypeTraits() always_check(TypeTraits::TIsReference::Value); always_check(TypeTraits::TIsReference::Value); - always_check(!TypeTraits::TIsMemberPointer::Value); - always_check(TypeTraits::TIsMemberPointer::Value); + always_check(!TypeTraits::TIsMemberPointer::Value); + always_check(TypeTraits::TIsMemberPointer::Value); + + // TypeProperties.h + + always_check(!TypeTraits::TIsConst::Value); + always_check(TypeTraits::TIsConst::Value); + always_check(!TypeTraits::TIsConst::Value); + always_check(TypeTraits::TIsConst::Value); + + always_check(!TypeTraits::TIsVolatile::Value); + always_check(!TypeTraits::TIsVolatile::Value); + always_check(TypeTraits::TIsVolatile::Value); + always_check(TypeTraits::TIsVolatile::Value); + + always_check(TypeTraits::TIsTrivial::Value); + always_check(!TypeTraits::TIsTrivial::Value); + + always_check(TypeTraits::TIsTriviallyCopyable::Value); + always_check(!TypeTraits::TIsTriviallyCopyable::Value); + always_check(!TypeTraits::TIsTriviallyCopyable::Value); + + always_check(TypeTraits::TIsStandardLayout::Value); + always_check(!TypeTraits::TIsStandardLayout::Value); + always_check(!TypeTraits::TIsStandardLayout::Value); + + always_check(TypeTraits::THasUniqueObjectRepresentations::Value); + always_check(!TypeTraits::THasUniqueObjectRepresentations::Value); + + always_check(TypeTraits::TIsEmpty::Value); + always_check(!TypeTraits::TIsEmpty::Value); + always_check(TypeTraits::TIsEmpty::Value); + always_check(TypeTraits::TIsEmpty::Value); + always_check(!TypeTraits::TIsEmpty::Value); + always_check(!TypeTraits::TIsEmpty::Value); + + always_check(TypeTraits::TIsPolymorphic::Value); + always_check(!TypeTraits::TIsPolymorphic::Value); + + always_check(TypeTraits::TIsAbstract::Value); + always_check(!TypeTraits::TIsAbstract::Value); + + always_check(!TypeTraits::TIsFinal::Value); + always_check(TypeTraits::TIsFinal::Value); + + always_check(!TypeTraits::TIsAggregate::Value); + always_check(TypeTraits::TIsAggregate::Value); + always_check(TypeTraits::TIsAggregate::Value); + always_check(!TypeTraits::TIsAggregate::Value); + + always_check(TypeTraits::TIsSigned::Value); + always_check(!TypeTraits::TIsSigned::Value); + + always_check(!TypeTraits::TIsUnsigned::Value); + always_check(TypeTraits::TIsUnsigned::Value); + + always_check(!TypeTraits::TIsBoundedArray::Value); + always_check(!TypeTraits::TIsBoundedArray::Value); + always_check(TypeTraits::TIsBoundedArray::Value); + + always_check(!TypeTraits::TIsUnboundedArray::Value); + always_check(TypeTraits::TIsUnboundedArray::Value); + always_check(!TypeTraits::TIsUnboundedArray::Value); + + always_check(!TypeTraits::TIsScopedEnum::Value); + always_check(TypeTraits::TIsScopedEnum::Value); } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h b/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h index 847c9ac..eea0349 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/PrimaryType.h @@ -25,19 +25,6 @@ template struct TIsUnion : TBoolConstant struct TIsClass : TBoolConstant> { }; template struct TIsFunction : TBoolConstant> { }; -NAMESPACE_PRIVATE_BEGIN - -static char(&Resolve(int))[2]; -static char Resolve(...); - -template -struct TIsEnumConvertibleToInt : TBoolConstant { }; - -NAMESPACE_PRIVATE_END - -template -struct TIsEnumClass : TBoolConstant, TNot>>::Value> { }; - NAMESPACE_END(TypeTraits) NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h b/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h new file mode 100644 index 0000000..bd31650 --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeProperties.h @@ -0,0 +1,45 @@ +#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 TIsConst : TBoolConstant> { }; +template struct TIsVolatile : TBoolConstant> { }; +template struct TIsTrivial : TBoolConstant> { }; +template struct TIsTriviallyCopyable : TBoolConstant> { }; +template struct TIsStandardLayout : TBoolConstant> { }; +template struct THasUniqueObjectRepresentations : TBoolConstant> { }; +template struct TIsEmpty : TBoolConstant> { }; +template struct TIsPolymorphic : TBoolConstant> { }; +template struct TIsAbstract : TBoolConstant> { }; +template struct TIsFinal : TBoolConstant> { }; +template struct TIsAggregate : TBoolConstant> { }; +template struct TIsSigned : TBoolConstant> { }; +template struct TIsUnsigned : TBoolConstant> { }; +template struct TIsBoundedArray : TBoolConstant> { }; +template struct TIsUnboundedArray : TBoolConstant> { }; + +NAMESPACE_PRIVATE_BEGIN + +char(&Resolve(int64))[2]; +char Resolve(...); + +template +struct TIsEnumConvertibleToInt : TBoolConstant { }; + +NAMESPACE_PRIVATE_END + +template +struct TIsScopedEnum : TBoolConstant, TNot>>::Value> { }; + +NAMESPACE_END(TypeTraits) +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END