refactor(templates): optimize the implementation of TOptional and TVariant
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include "Templates/TypeHash.h"
|
||||
#include "Concepts/Comparable.h"
|
||||
#include "TypeTraits/TypeTraits.h"
|
||||
#include "Miscellaneous/Compare.h"
|
||||
#include "Miscellaneous/AssertionMacros.h"
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
@ -262,6 +263,14 @@ constexpr bool operator==(const TOptional<T>& LHS, const TOptional<U>& RHS)
|
||||
return *LHS == *RHS;
|
||||
}
|
||||
|
||||
template <typename T, typename U> requires CSynthThreeWayComparableWith<T, U>
|
||||
constexpr partial_ordering operator<=>(const TOptional<T>& LHS, const TOptional<U>& RHS)
|
||||
{
|
||||
if (LHS.IsValid() != RHS.IsValid()) return partial_ordering::unordered;
|
||||
if (LHS.IsValid() == false) return partial_ordering::equivalent;
|
||||
return SynthThreeWayCompare(*LHS, *RHS);
|
||||
}
|
||||
|
||||
template <typename T, typename U> requires CWeaklyEqualityComparableWith<T, U>
|
||||
constexpr bool operator==(const TOptional<T>& LHS, const U& RHS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user