UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UEOps.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Concepts/SameAs.h"
6#include "HAL/Platform.h"
7
8namespace UE::Core::Private
9{
10 // This only exists to bind to NULL, which is not perfectly-forwardable but which is commonly used in comparison operators.
11 // The type is unique so that it can't be confused with a type that will actually be used by real user code, and it used to
12 // create a pointer-to-member type which is highly unlikely to be deduced.
13 struct FIncomplete;
14
15 template <typename LhsType, typename RhsType>
16 concept CWithUEOpEquals = requires(const LhsType & Lhs, const RhsType & Rhs)
17 {
18 { Lhs.UEOpEquals(Rhs) } -> UE::CSameAs<bool>;
19 };
20
21 template <typename LhsType, typename RhsType>
22 concept CWithUEOpLessThan = requires(const LhsType & Lhs, const RhsType & Rhs)
23 {
24 { Lhs.UEOpLessThan(Rhs) } -> UE::CSameAs<bool>;
25 };
26
27 template <typename LhsType, typename RhsType>
28 concept CWithUEOpGreaterThan = requires(const LhsType & Lhs, const RhsType & Rhs)
29 {
30 { Lhs.UEOpGreaterThan(Rhs) } -> UE::CSameAs<bool>;
31 };
32}
33
52template <typename LhsType, typename RhsType>
54[[nodiscard]] UE_REWRITE constexpr bool operator==(const LhsType& Lhs, const RhsType& Rhs)
55{
57 {
58 return Lhs.UEOpEquals(Rhs);
59 }
60 else
61 {
62 return Rhs.UEOpEquals(Lhs);
63 }
64}
65
66// This overload exists to support A == NULL, which is common in comparison operators, but NULL is not perfectly-forwardable.
67template <typename LhsType>
68 requires UE::Core::Private::CWithUEOpEquals<LhsType, decltype(nullptr)>
69[[nodiscard]] UE_REWRITE constexpr bool operator==(const LhsType& Lhs, int UE::Core::Private::FIncomplete::* Rhs)
70{
71 return Lhs.UEOpEquals(nullptr);
72}
73
74template <typename LhsType, typename RhsType>
76[[nodiscard]] UE_REWRITE constexpr bool operator<(const LhsType& Lhs, const RhsType& Rhs)
77{
79 {
80 return Lhs.UEOpLessThan(Rhs);
81 }
82 else
83 {
84 return Rhs.UEOpGreaterThan(Lhs);
85 }
86}
87
88template <typename LhsType, typename RhsType>
90[[nodiscard]] UE_REWRITE constexpr bool operator>(const LhsType& Lhs, const RhsType& Rhs)
91{
93 {
94 return Rhs.UEOpLessThan(Lhs);
95 }
96 else
97 {
98 return Lhs.UEOpGreaterThan(Rhs);
99 }
100}
101
102template <typename LhsType, typename RhsType>
104[[nodiscard]] UE_REWRITE constexpr bool operator>=(const LhsType& Lhs, const RhsType& Rhs)
105{
107 {
108 return !Lhs.UEOpLessThan(Rhs);
109 }
110 else
111 {
112 return !Rhs.UEOpGreaterThan(Lhs);
113 }
114}
115
116template <typename LhsType, typename RhsType>
118[[nodiscard]] UE_REWRITE constexpr bool operator<=(const LhsType& Lhs, const RhsType& Rhs)
119{
121 {
122 return !Rhs.UEOpLessThan(Lhs);
123 }
124 else
125 {
126 return !Lhs.UEOpGreaterThan(Rhs);
127 }
128}
129
130#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_7
131#include "Templates/Requires.h"
132#endif
#define UE_REWRITE
Definition Platform.h:747
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_REWRITE constexpr bool operator>(const LhsType &Lhs, const RhsType &Rhs)
Definition UEOps.h:90
UE_REWRITE constexpr bool operator==(const LhsType &Lhs, const RhsType &Rhs)
Definition UEOps.h:54
UE_REWRITE constexpr bool operator<=(const LhsType &Lhs, const RhsType &Rhs)
Definition UEOps.h:118
UE_REWRITE constexpr bool operator<(const LhsType &Lhs, const RhsType &Rhs)
Definition UEOps.h:76
UE_REWRITE constexpr bool operator>=(const LhsType &Lhs, const RhsType &Rhs)
Definition UEOps.h:104
UE_FORCEINLINE_HINT bool UEOpGreaterThan(const CharType *Rhs) const
Definition UnrealString.h.inl:921
bool UEOpEquals(FIntrusiveUnsetOptionalState Tag) const
Definition UnrealString.h.inl:219
UE_FORCEINLINE_HINT bool UEOpLessThan(const UE_STRING_CLASS &Rhs) const
Definition UnrealString.h.inl:893
Definition SameAs.h:16
implementation
Definition PlayInEditorLoadingScope.h:8