diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index 5b47fb0..c9154bb 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -249,6 +249,30 @@ constexpr bool operator!=(const T& LHS, const TOptional& RHS) return RHS.IsValid() ? LHS != *RHS : true; } +template +constexpr bool operator==(const TOptional& LHS, FInvalid) +{ + return !LHS.IsValid(); +} + +template +constexpr bool operator!=(const TOptional& LHS, FInvalid) +{ + return LHS.IsValid(); +} + +template +constexpr bool operator==(FInvalid, const TOptional& RHS) +{ + return !RHS.IsValid(); +} + +template +constexpr bool operator!=(FInvalid, const TOptional& RHS) +{ + return RHS.IsValid(); +} + template constexpr TOptional::Type> MakeOptional(FInvalid) { diff --git a/Redcraft.Utility/Source/Public/Templates/Variant.h b/Redcraft.Utility/Source/Public/Templates/Variant.h index 4f80f92..53baa2f 100644 --- a/Redcraft.Utility/Source/Public/Templates/Variant.h +++ b/Redcraft.Utility/Source/Public/Templates/Variant.h @@ -4,6 +4,7 @@ #include "Templates/Invoke.h" #include "Templates/Utility.h" #include "TypeTraits/TypeTraits.h" +#include "Miscellaneous/AssertionMacros.h" NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) @@ -474,6 +475,30 @@ constexpr bool operator!=(const T& LHS, const TVariant& RHS) return RHS.template HoldsAlternative() ? LHS != RHS.template GetValue() : true; } +template +constexpr bool operator==(const TVariant& LHS, FInvalid) +{ + return !LHS.IsValid(); +} + +template +constexpr bool operator!=(const TVariant& LHS, FInvalid) +{ + return LHS.IsValid(); +} + +template +constexpr bool operator==(FInvalid, const TVariant& RHS) +{ + return !RHS.IsValid(); +} + +template +constexpr bool operator!=(FInvalid, const TVariant& RHS) +{ + return RHS.IsValid(); +} + template requires (true && ... && (TIsMoveConstructible::Value && TIsSwappable::Value)) constexpr void Swap(TVariant& A, TVariant& B) {