From 91755d2196702c51f4d9591d5d5c3fa3863e92ab Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Sat, 26 Mar 2022 19:33:28 +0800 Subject: [PATCH] feat(templates): add TUnwrapReference and the corresponding testing --- Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp | 3 +++ Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index 27ce98a..a5f01e5 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -75,6 +75,9 @@ void TestReferenceWrapper() always_check(ArrayA[0] == 2); always_check(ArrayA[1] == 4); always_check(ArrayA[2] == 6); + + always_check((TIsSame::Type>::Value)); + always_check((TIsSame>::Type>::Value)); } void TestOptional() diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index 579acd2..c28dc9e 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -40,6 +40,11 @@ private: template TReferenceWrapper(T&) -> TReferenceWrapper; +template struct TUnwrapReference { using Type = T; }; +template struct TUnwrapReference> { using Type = T&; }; + +template struct TUnwrapRefDecay { using Type = typename TUnwrapReference::Type>::Type; }; + NAMESPACE_MODULE_END(Utility) NAMESPACE_MODULE_END(Redcraft) NAMESPACE_REDCRAFT_END