diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index a36a1d2..eb464c2 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -4,6 +4,7 @@ #include "TypeTraits/PrimaryType.h" #include "TypeTraits/CompositeType.h" #include "TypeTraits/TypeProperties.h" +#include "TypeTraits/SupportedOperations.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) @@ -22,6 +23,20 @@ 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 { } }; +struct FTestStructI { int32 MemberA; double MemberB; FTestStructI(int32 A, double B) { } FTestStructI& operator=(int32) { return *this; }; }; +struct FTestStructJ { int32 MemberA; double MemberB; FTestStructJ() { }; }; +struct FTestStructK { int32 MemberA; double MemberB; FTestStructK() = default; }; +struct FTestStructL { int32 MemberA; double MemberB; FTestStructL() = delete; }; +struct FTestStructM { int32 MemberA; double MemberB; FTestStructM(const FTestStructM&) { }; FTestStructM& operator=(const FTestStructM&) { return *this; }; }; +struct FTestStructN { int32 MemberA; double MemberB; FTestStructN(const FTestStructN&) = default; FTestStructN& operator=(const FTestStructN&) = default; }; +struct FTestStructO { int32 MemberA; double MemberB; FTestStructO(const FTestStructO&) = delete; FTestStructO& operator=(const FTestStructO&) = delete; }; +struct FTestStructP { int32 MemberA; double MemberB; FTestStructP(FTestStructP&&) { }; FTestStructP& operator=(FTestStructP&&) { return *this; }; }; +struct FTestStructQ { int32 MemberA; double MemberB; FTestStructQ(FTestStructQ&&) = default; FTestStructQ& operator=(FTestStructQ&&) = default; }; +struct FTestStructR { int32 MemberA; double MemberB; FTestStructR(FTestStructR&&) = delete; FTestStructR& operator=(FTestStructR&&) = delete; }; +struct FTestStructS { int32 MemberA; double MemberB; ~FTestStructS() { } }; +struct FTestStructT { int32 MemberA; double MemberB; ~FTestStructT() = default; }; +struct FTestStructU { int32 MemberA; double MemberB; ~FTestStructU() = delete; }; +struct FTestStructV { int32 MemberA; double MemberB; virtual ~FTestStructV() { }; }; enum ETestEnum { }; enum class ETestEnumClass { }; @@ -215,6 +230,77 @@ void TestTypeTraits() always_check(!TypeTraits::TIsScopedEnum::Value); always_check(TypeTraits::TIsScopedEnum::Value); + + // SupportedOperations.h + + always_check(!TypeTraits::TIsDefaultConstructible::Value); + always_check(TypeTraits::TIsDefaultConstructible::Value); + always_check(TypeTraits::TIsDefaultConstructible::Value); + always_check(!TypeTraits::TIsDefaultConstructible::Value); + + always_check(!TypeTraits::TIsTriviallyDefaultConstructible::Value); + always_check(!TypeTraits::TIsTriviallyDefaultConstructible::Value); + always_check(TypeTraits::TIsTriviallyDefaultConstructible::Value); + always_check(!TypeTraits::TIsTriviallyDefaultConstructible::Value); + + always_check(!(TypeTraits::TIsConstructible::Value)); + always_check((TypeTraits::TIsConstructible::Value)); + always_check((TypeTraits::TIsConstructible::Value)); + + always_check(!(TypeTraits::TIsTriviallyConstructible::Value)); + always_check((TypeTraits::TIsTriviallyConstructible::Value)); + always_check(!(TypeTraits::TIsTriviallyConstructible::Value)); + + always_check(TypeTraits::TIsCopyConstructible::Value); + always_check(TypeTraits::TIsCopyConstructible::Value); + always_check(!TypeTraits::TIsCopyConstructible::Value); + + always_check(!TypeTraits::TIsTriviallyCopyConstructible::Value); + always_check(TypeTraits::TIsTriviallyCopyConstructible::Value); + always_check(!TypeTraits::TIsTriviallyCopyConstructible::Value); + + always_check(TypeTraits::TIsMoveConstructible::Value); + always_check(TypeTraits::TIsMoveConstructible::Value); + always_check(!TypeTraits::TIsMoveConstructible::Value); + + always_check(!TypeTraits::TIsTriviallyMoveConstructible::Value); + always_check(TypeTraits::TIsTriviallyMoveConstructible::Value); + always_check(!TypeTraits::TIsTriviallyMoveConstructible::Value); + + always_check(!(TypeTraits::TIsAssignable::Value)); + always_check((TypeTraits::TIsAssignable::Value)); + always_check((TypeTraits::TIsAssignable::Value)); + + always_check(!(TypeTraits::TIsTriviallyAssignable::Value)); + always_check((TypeTraits::TIsTriviallyAssignable::Value)); + always_check(!(TypeTraits::TIsTriviallyAssignable::Value)); + + always_check(TypeTraits::TIsCopyAssignable::Value); + always_check(TypeTraits::TIsCopyAssignable::Value); + always_check(!TypeTraits::TIsCopyAssignable::Value); + + always_check(!TypeTraits::TIsTriviallyCopyAssignable::Value); + always_check(TypeTraits::TIsTriviallyCopyAssignable::Value); + always_check(!TypeTraits::TIsTriviallyCopyAssignable::Value); + + always_check(TypeTraits::TIsMoveAssignable::Value); + always_check(TypeTraits::TIsMoveAssignable::Value); + always_check(!TypeTraits::TIsMoveAssignable::Value); + + always_check(!TypeTraits::TIsTriviallyMoveAssignable::Value); + always_check(TypeTraits::TIsTriviallyMoveAssignable::Value); + always_check(!TypeTraits::TIsTriviallyMoveAssignable::Value); + + always_check(TypeTraits::TIsDestructible::Value); + always_check(TypeTraits::TIsDestructible::Value); + always_check(!TypeTraits::TIsDestructible::Value); + + always_check(!TypeTraits::TIsTriviallyDestructible::Value); + always_check(TypeTraits::TIsTriviallyDestructible::Value); + always_check(!TypeTraits::TIsTriviallyDestructible::Value); + + always_check(!TypeTraits::THasVirtualDestructor::Value); + always_check(TypeTraits::THasVirtualDestructor::Value); } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h b/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h new file mode 100644 index 0000000..b01caae --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/SupportedOperations.h @@ -0,0 +1,51 @@ +#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 TIsDefaultConstructible : TBoolConstant> { }; +template struct TIsCopyConstructible : TBoolConstant> { }; +template struct TIsMoveConstructible : TBoolConstant> { }; +template struct TIsCopyAssignable : TBoolConstant> { }; +template struct TIsMoveAssignable : TBoolConstant> { }; +template struct TIsDestructible : TBoolConstant> { }; +template struct TIsTriviallyDefaultConstructible : TBoolConstant> { }; +template struct TIsTriviallyCopyConstructible : TBoolConstant> { }; +template struct TIsTriviallyMoveConstructible : TBoolConstant> { }; +template struct TIsTriviallyCopyAssignable : TBoolConstant> { }; +template struct TIsTriviallyMoveAssignable : TBoolConstant> { }; +template struct TIsTriviallyDestructible : TBoolConstant> { }; +template struct THasVirtualDestructor : TBoolConstant> { }; + +//template struct TIsSwappable; +//template struct TIsNothrowDefaultConstructible; +//template struct TIsNothrowCopyConstructible; +//template struct TIsNothrowMoveConstructible; +//template struct TIsNothrowCopyAssignable; +//template struct TIsNothrowMoveAssignable; +//template struct TIsNothrowSwappable; +//template struct TIsNothrowDestructible; + +template struct TIsAssignable : TBoolConstant> { }; +template struct TIsTriviallyAssignable : TBoolConstant> { }; + +//template struct TIsSwappableWith; +//template struct TIsNothrowAssignable; +//template struct TIsNothrowSwappableWith; + +template struct TIsConstructible : TBoolConstant> { }; +template struct TIsTriviallyConstructible : TBoolConstant> { }; + +//template struct TIsNothrowConstructible; + +NAMESPACE_END(TypeTraits) +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END