From f7b611febc8ae009f9092605906fc7e8f41544b3 Mon Sep 17 00:00:00 2001 From: _Redstone_c_ Date: Tue, 15 Mar 2022 11:52:46 +0800 Subject: [PATCH] fix(templates): fix TOptional's operator!= returned an wrong value for invalid value --- Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp | 1 + Redcraft.Utility/Source/Public/Templates/Optional.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp index 82dcd40..56bec7f 100644 --- a/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp +++ b/Redcraft.Utility/Source/Private/Testing/TemplatesTesting.cpp @@ -230,6 +230,7 @@ void TestOptional() TempO.Reset(); always_check(TempO == TempO); + always_check(!(TempO != TempO)); always_check(TempO.Get(500) == 500); int32 TempP = 200; diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index bb94f3a..16eda27 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -223,7 +223,7 @@ template constexpr bool operator!=(const TOptional& LHS, const TOptional& RHS) { if (LHS.IsValid() != RHS.IsValid()) return true; - if (LHS.IsValid() == false) return true; + if (LHS.IsValid() == false) return false; return *LHS != *RHS; }