From f3471327259747b1a8ad1784a6e233f542ff7a49 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Tue, 15 Nov 2022 22:15:10 +0800 Subject: [PATCH] fix(templates): fix compile error in TReferenceWrapper constructor --- .../Public/Templates/ReferenceWrapper.h | 6 +++++- .../Source/Public/Templates/Utility.h | 20 +++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h index 54b7b0c..3ceb3ff 100644 --- a/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h +++ b/Redcraft.Utility/Source/Public/Templates/ReferenceWrapper.h @@ -18,7 +18,11 @@ public: using Type = ReferencedType; template requires CConvertibleTo - constexpr TReferenceWrapper(T&& Object) : Pointer(AddressOf(Forward(Object))) { } + constexpr TReferenceWrapper(T&& Object) + { + ReferencedType& Reference = Forward(Object); + Pointer = AddressOf(Reference); + } TReferenceWrapper(const TReferenceWrapper&) = default; diff --git a/Redcraft.Utility/Source/Public/Templates/Utility.h b/Redcraft.Utility/Source/Public/Templates/Utility.h index 6586333..d76e814 100644 --- a/Redcraft.Utility/Source/Public/Templates/Utility.h +++ b/Redcraft.Utility/Source/Public/Templates/Utility.h @@ -21,38 +21,38 @@ void AsConst(const T&& Ref) = delete; template constexpr TRemoveReference&& MoveTemp(T&& Obj) { - typedef TRemoveReference CastType; - return (CastType&&)Obj; + using CastType = TRemoveReference; + return static_cast(Obj); } template -constexpr T CopyTemp(T& Val) +constexpr T CopyTemp(T& Obj) { - return const_cast(Val); + return const_cast(Obj); } template -constexpr T CopyTemp(const T& Val) +constexpr T CopyTemp(const T& Obj) { - return Val; + return Obj; } template -constexpr T&& CopyTemp(T&& Val) +constexpr T&& CopyTemp(T&& Obj) { - return MoveTemp(Val); + return MoveTemp(Obj); } template constexpr T&& Forward(TRemoveReference& Obj) { - return (T&&)Obj; + return static_cast(Obj); } template constexpr T&& Forward(TRemoveReference&& Obj) { - return (T&&)Obj; + return static_cast(Obj); } template requires requires(T& A, T& B) { A.Swap(B); }