TSharedPtr::UEOpEquals
#include "Templates/SharedPointer.h"
Access: public
Specifiers: inline
Description
Internal equality helper used by the UE operator== rewrite infrastructure. Compares two TSharedPtr instances by their raw Object pointer. Also has overloads accepting TWeakPtr, nullptr, and FIntrusiveUnsetOptionalState.
Caveats & Gotchas
- • UEOpEquals is not the same as operator==. It is called by the UE_REWRITE-generated operator== and should not be invoked directly in user code — use == instead.
- • The FIntrusiveUnsetOptionalState overload returns true when Object equals (ObjectType*)-1, which is the sentinel value used by TOptional<TSharedPtr> to represent an unset state. This is an internal TOptional integration detail.
- • Two TSharedPtr instances that point to the same object but were created independently (e.g. two TSharedPtr wrapping the same raw pointer without a shared controller) will compare equal even though they represent a double-ownership bug.
Signature
template <typename OtherType>
[[nodiscard]] inline bool UEOpEquals(const TSharedPtr<OtherType, Mode>& Rhs) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Rhs | const TSharedPtr<OtherType, Mode>& | The other shared pointer to compare against. | — |
Return Type
bool Example
Using == (which dispatches to UEOpEquals internally) C++
TSharedPtr<FMyData> A = MakeShared<FMyData>();
TSharedPtr<FMyData> B = A;
TSharedPtr<FMyData> C = MakeShared<FMyData>();
check(A == B); // true — same object
check(A != C); // true — different objects
check(A != nullptr); // false — A is valid See Also
Tags
Version History
Introduced in: 5.3
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?