feat(templates): add TOptional and TVariant to compare the equivalence of Invalid
This commit is contained in:
parent
be1d91591c
commit
2f55c84c32
@ -249,6 +249,30 @@ constexpr bool operator!=(const T& LHS, const TOptional<U>& RHS)
|
|||||||
return RHS.IsValid() ? LHS != *RHS : true;
|
return RHS.IsValid() ? LHS != *RHS : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr bool operator==(const TOptional<T>& LHS, FInvalid)
|
||||||
|
{
|
||||||
|
return !LHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr bool operator!=(const TOptional<T>& LHS, FInvalid)
|
||||||
|
{
|
||||||
|
return LHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr bool operator==(FInvalid, const TOptional<T>& RHS)
|
||||||
|
{
|
||||||
|
return !RHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr bool operator!=(FInvalid, const TOptional<T>& RHS)
|
||||||
|
{
|
||||||
|
return RHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr TOptional<typename TDecay<T>::Type> MakeOptional(FInvalid)
|
constexpr TOptional<typename TDecay<T>::Type> MakeOptional(FInvalid)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "Templates/Invoke.h"
|
#include "Templates/Invoke.h"
|
||||||
#include "Templates/Utility.h"
|
#include "Templates/Utility.h"
|
||||||
#include "TypeTraits/TypeTraits.h"
|
#include "TypeTraits/TypeTraits.h"
|
||||||
|
#include "Miscellaneous/AssertionMacros.h"
|
||||||
|
|
||||||
NAMESPACE_REDCRAFT_BEGIN
|
NAMESPACE_REDCRAFT_BEGIN
|
||||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||||
@ -474,6 +475,30 @@ constexpr bool operator!=(const T& LHS, const TVariant<Types...>& RHS)
|
|||||||
return RHS.template HoldsAlternative<T>() ? LHS != RHS.template GetValue<T>() : true;
|
return RHS.template HoldsAlternative<T>() ? LHS != RHS.template GetValue<T>() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename... Types>
|
||||||
|
constexpr bool operator==(const TVariant<Types...>& LHS, FInvalid)
|
||||||
|
{
|
||||||
|
return !LHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Types>
|
||||||
|
constexpr bool operator!=(const TVariant<Types...>& LHS, FInvalid)
|
||||||
|
{
|
||||||
|
return LHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Types>
|
||||||
|
constexpr bool operator==(FInvalid, const TVariant<Types...>& RHS)
|
||||||
|
{
|
||||||
|
return !RHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Types>
|
||||||
|
constexpr bool operator!=(FInvalid, const TVariant<Types...>& RHS)
|
||||||
|
{
|
||||||
|
return RHS.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename... Types> requires (true && ... && (TIsMoveConstructible<Types>::Value && TIsSwappable<Types>::Value))
|
template <typename... Types> requires (true && ... && (TIsMoveConstructible<Types>::Value && TIsSwappable<Types>::Value))
|
||||||
constexpr void Swap(TVariant<Types...>& A, TVariant<Types...>& B)
|
constexpr void Swap(TVariant<Types...>& A, TVariant<Types...>& B)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user