From d634fc3cf80ba0a3aa315eb43b9ec72874e89e32 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Wed, 27 Apr 2022 23:22:52 +0800 Subject: [PATCH] fix(templates): fix TOptional constraints and implementation --- .../Source/Public/Templates/Optional.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index dfc3634..4428d32 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -26,6 +26,10 @@ private: || TIsConvertible&, OptionalType>::Value || TIsConvertible< TOptional&&, OptionalType>::Value || TIsConvertible&&, OptionalType>::Value + || TIsAssignable& >::Value + || TIsAssignable& >::Value + || TIsAssignable&&>::Value + || TIsAssignable&&>::Value )> { }; public: @@ -120,11 +124,9 @@ public: return *this; } - template requires TIsConstructible::Value && TIsAssignable::Value && TAllowUnwrapping::Value + template requires TIsConstructible::Value && TIsAssignable::Value && TAllowUnwrapping::Value constexpr TOptional& operator=(const TOptional& InValue) { - if (&InValue == this) return *this; - if (!InValue.IsValid()) { Reset(); @@ -141,11 +143,9 @@ public: return *this; } - template requires TIsConstructible::Value && TIsAssignable::Value && TAllowUnwrapping::Value + template requires TIsConstructible::Value && TIsAssignable::Value && TAllowUnwrapping::Value constexpr TOptional& operator=(TOptional&& InValue) { - if (&InValue == this) return *this; - if (!InValue.IsValid()) { Reset(); @@ -162,7 +162,7 @@ public: return *this; } - template requires TIsConstructible::Value && TIsAssignable::Value + template requires TIsConstructible::Value && TIsAssignable::Value constexpr TOptional& operator=(T&& InValue) { if (IsValid()) GetValue() = Forward(InValue);