From d825285a4a41916a0f952b9f53cba3edf0097fdb Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Sun, 8 Jan 2023 18:03:05 +0800 Subject: [PATCH] feat(typetraits): add CDerivedFrom and the corresponding testing --- Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp | 4 ++++ Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h | 1 + 2 files changed, 5 insertions(+) diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index bef5256..ce2a98f 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -322,6 +322,10 @@ void TestTypeTraits() always_check(!(CConvertibleTo)); always_check((CConvertibleTo)); + always_check(!(CDerivedFrom)); + always_check(!(CDerivedFrom)); + always_check((CDerivedFrom)); + always_check((CSameAs>)); always_check(!(CSameAs>)); always_check(!(CSameAs>)); diff --git a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h index db539a8..afbe446 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/Miscellaneous.h @@ -31,6 +31,7 @@ template inline constexpr size_t TExtent = NAMESPACE template concept CSameAs = NAMESPACE_STD::is_same_v; template concept CBaseOf = NAMESPACE_STD::is_base_of_v; template concept CConvertibleTo = NAMESPACE_STD::is_convertible_v; +template concept CDerivedFrom = CBaseOf && CConvertibleTo; template using TRemoveConst = NAMESPACE_STD::remove_const_t; template using TRemoveVolatile = NAMESPACE_STD::remove_volatile_t;