From 8188d29a587cab9d4593ff0c9f29d8ed4592a9cd Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Tue, 15 Mar 2022 14:25:06 +0800 Subject: [PATCH] feat(typetraits): add TypeTraits/CopyQualifiers.h and the corresponding testing --- .../Private/Testing/TypeTraitsTesting.cpp | 78 +++++++++++++++++++ .../Source/Public/TypeTraits/CopyQualifiers.h | 36 +++++++++ .../Source/Public/TypeTraits/TypeTraits.h | 1 + 3 files changed, 115 insertions(+) create mode 100644 Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h diff --git a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp index 2e0e5cd..23933af 100644 --- a/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TypeTraitsTesting.cpp @@ -450,6 +450,84 @@ void TestTypeTraits() always_check((TIsSwappableWith::Value)); + // CopyQualifiers.h + + always_check((TIsSame< int32, TCopyConst< int32, int32>::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame< int32, TCopyVolatile< int32, int32>::Type>::Value)); + always_check((TIsSame< int32, TCopyVolatile::Type>::Value)); + always_check((TIsSame< volatile int32, TCopyVolatile::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame< int32, TCopyCV< int32, int32>::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame< int32, TCopyCVRef< int32, int32>::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame< volatile int32, TCopyCVRef< volatile int32, int32>::Type>::Value)); + always_check((TIsSame< volatile int32, TCopyCVRef< int32, volatile int32>::Type>::Value)); + always_check((TIsSame< volatile int32, TCopyCVRef< volatile int32, volatile int32>::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + always_check((TIsSame::Type>::Value)); + } NAMESPACE_MODULE_END(Utility) diff --git a/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h b/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h new file mode 100644 index 0000000..588082b --- /dev/null +++ b/Redcraft.Utility/Source/Public/TypeTraits/CopyQualifiers.h @@ -0,0 +1,36 @@ +#pragma once + +#include "CoreTypes.h" +#include "TypeTraits/HelperClasses.h" + +#include + +NAMESPACE_REDCRAFT_BEGIN +NAMESPACE_MODULE_BEGIN(Redcraft) +NAMESPACE_MODULE_BEGIN(Utility) + +template struct TCopyConst { using Type = To; }; +template struct TCopyConst { using Type = const To; }; + +template struct TCopyVolatile { using Type = To; }; +template struct TCopyVolatile { using Type = volatile To; }; + +template struct TCopyCV { using Type = typename TCopyConst::Type>::Type; }; + +template struct TCopyReference { using Type = To; }; +template struct TCopyReference { using Type = To&; }; +template struct TCopyReference { using Type = To&&; }; + +template struct TCopyCVRef { using Type = typename TCopyCV::Type; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&; }; +template struct TCopyCVRef { using Type = typename TCopyCV::Type&&; }; + +NAMESPACE_MODULE_END(Utility) +NAMESPACE_MODULE_END(Redcraft) +NAMESPACE_REDCRAFT_END diff --git a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h index 0c02e41..8ed0163 100644 --- a/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h +++ b/Redcraft.Utility/Source/Public/TypeTraits/TypeTraits.h @@ -9,3 +9,4 @@ #include "TypeTraits/Miscellaneous.h" #include "TypeTraits/Swappable.h" #include "TypeTraits/Common.h" +#include "TypeTraits/CopyQualifiers.h"