UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ObjectPtr.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "HAL/Platform.h"
6#include "Misc/UEOps.h"
13
14#include <type_traits>
15
16#define UE_WITH_OBJECT_PTR_DEPRECATIONS 0
17#if UE_WITH_OBJECT_PTR_DEPRECATIONS
18 #define UE_OBJPTR_DEPRECATED(Version, Message) UE_DEPRECATED(Version, Message)
19#else
20 #define UE_OBJPTR_DEPRECATED(Version, Message)
21#endif
22
23#ifndef UE_OBJECT_PTR_GC_BARRIER
24 #define UE_OBJECT_PTR_GC_BARRIER 1
25#endif
26
27
34#define UE_TRANSITIONAL_OBJECT_PTR(Type) auto
35#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE(Templ, Type) auto
36#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE_SUFFIXED(Templ, Type, Suffix) auto
37#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG1(Templ, Type1, Type2) auto
38#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG1_SUFFIXED(Templ, Type1, Type2, Suffix) auto
39#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG2(Templ, Type1, Type2) auto
40#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG2_SUFFIXED(Templ, Type1, Type2, Suffix) auto
41#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG_BOTH(Templ, Type1, Type2) auto
42#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG_BOTH_SUFFIXED(Templ, Type1, Type2, Suffix) auto
43
44#define UE_OBJECT_PTR_NONCONFORMANCE_SUPPORT 0 UE_DEPRECATED_MACRO(5.6, "UE_OBJECT_PTR_NONCONFORMANCE_SUPPORT has been deprecated and shouldn't be used")
45
46class UClass;
47
48template <typename T>
49struct TObjectPtr;
50
55{
56public:
57 [[nodiscard]] constexpr FObjectPtr()
58 : Handle(UE::CoreUObject::Private::MakeObjectHandle(nullptr))
59 {
60 }
61
62 [[nodiscard]] explicit constexpr FObjectPtr(ENoInit)
63 {
64 }
65
67 : Handle(UE::CoreUObject::Private::MakeObjectHandle(nullptr))
68 {
69 }
70
72 : Handle(UE::CoreUObject::Private::MakeObjectHandle(Object))
73 {
74#if UE_OBJECT_PTR_GC_BARRIER
75 ConditionallyMarkAsReachable(Object);
76#endif // UE_OBJECT_PTR_GC_BARRIER
77 }
78
79 UE_OBJPTR_DEPRECATED(5.0, "Construction with incomplete type pointer is deprecated. Please update this code to use MakeObjectPtrUnsafe.")
84
85#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_REMOTE_OBJECT_HANDLE
87 : Handle(Handle)
88 {
89#if UE_OBJECT_PTR_GC_BARRIER
90 ConditionallyMarkAsReachable(*this);
91#endif // UE_OBJECT_PTR_GC_BARRIER
92 }
93#endif
94
96#if UE_WITH_REMOTE_OBJECT_HANDLE
97 : FObjectPtr(UE::CoreUObject::Private::FRemoteObjectHandlePrivate::FromIdNoResolve(ObjectId))
98#else
99 : FObjectPtr()
100#endif
101 {
102 }
103
108
113
114
115#if UE_OBJECT_PTR_GC_BARRIER
118 {
119 ConditionallyMarkAsReachable(*this);
120 }
121
124 {
125 ConditionallyMarkAsReachable(*this);
126 }
127
129 {
130 ConditionallyMarkAsReachable(InOther);
131 Handle = MoveTemp(InOther.Handle);
132 return *this;
133 }
134
136 {
137 ConditionallyMarkAsReachable(InOther);
138 Handle = InOther.Handle;
139 return *this;
140 }
141#else
142 [[nodiscard]] constexpr FObjectPtr(FObjectPtr&&) = default;
143 [[nodiscard]] constexpr FObjectPtr(const FObjectPtr&) = default;
144 FObjectPtr& operator=(FObjectPtr&&) = default;
145 FObjectPtr& operator=(const FObjectPtr&) = default;
146#endif // UE_OBJECT_PTR_GC_BARRIER
147
149 {
150#if UE_OBJECT_PTR_GC_BARRIER
151 ConditionallyMarkAsReachable(Other);
152#endif // UE_OBJECT_PTR_GC_BARRIER
154 return *this;
155 }
156
157 UE_OBJPTR_DEPRECATED(5.0, "Assignment with incomplete type pointer is deprecated. Please update this code to use MakeObjectPtrUnsafe.")
158 FObjectPtr& operator=(void* IncompleteOther)
159 {
161 return *this;
162 }
163
169
171 {
172 return (Handle == Other.Handle);
173 }
174
175 UE_OBJPTR_DEPRECATED(5.0, "Use of ToTObjectPtr is unsafe and is deprecated.")
177 UE_OBJPTR_DEPRECATED(5.0, "Use of ToTObjectPtr is unsafe and is deprecated.")
179
180 [[nodiscard]] FORCEINLINE UObject* operator->() const { return Get(); }
181 [[nodiscard]] FORCEINLINE UObject& operator*() const { return *Get(); }
182
184 [[nodiscard]] explicit FORCEINLINE operator bool() const { return !IsObjectHandleNull(Handle); }
185
187
192 [[nodiscard]] FORCEINLINE bool IsRemote() const { return !IsResolved(); }
193
194 // Gets the PathName of the object without resolving the object reference.
195 // @TODO OBJPTR: Deprecate this.
196 [[nodiscard]] FString GetPath() const { return GetPathName(); }
197
198#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_REMOTE_OBJECT_HANDLE
199 // Gets the PathName of the object without resolving the object reference.
200 [[nodiscard]] COREUOBJECT_API FString GetPathName() const;
201
202 // Gets the FName of the object without resolving the object reference.
204
205 // Gets the string name of the object without resolving the object reference.
206 [[nodiscard]] FORCEINLINE FString GetName() const
207 {
208 return GetFName().ToString();
209 }
210
211 // Gets the Outer UObject for this Object without resolving the object reference.
213
214 // Gets the package for this Object without resolving the object reference.
216
217 // Reports whether this Object is within an Outer or Package. In some cases may need to resolve the object reference.
219
222#else
223 [[nodiscard]] FString GetPathName() const
224 {
225 const UObject* ResolvedObject = Get();
227 }
228
234
235 [[nodiscard]] FString GetName() const
236 {
237 return GetFName().ToString();
238 }
239
245
251
259
265 {
266 // UObjectBaseUtility::GetFullName is safe to call on null objects.
268 }
269#endif
270
273
274 [[nodiscard]] COREUOBJECT_API bool IsA(const UClass* SomeBase) const;
275
276 template <typename T>
277 [[nodiscard]] FORCEINLINE bool IsA() const
278 {
279 return IsA(T::StaticClass());
280 }
281
283 {
284#if UE_WITH_REMOTE_OBJECT_HANDLE
285 return GetHandle().GetRemoteId();
286#else
287 return FRemoteObjectId();
288#endif
289 }
290
291private:
293 {
294 return GetTypeHash(Object.Handle);
295 }
296
297 union
298 {
300 // DebugPtr allows for easier dereferencing of a resolved FObjectPtr in watch windows of debuggers. If the address in the pointer
301 // is an odd/uneven number, that means the object reference is unresolved and you will not be able to dereference it successfully.
303 };
304
305#if UE_OBJECT_PTR_GC_BARRIER
306 FORCEINLINE constexpr void ConditionallyMarkAsReachable(const FObjectPtr& InPtr) const
307 {
309 {
311 {
313 {
315 }
316 }
317 }
318 }
319 FORCEINLINE constexpr void ConditionallyMarkAsReachable(const UObject* InObj) const
320 {
322 {
324 {
326 }
327 }
328 }
329#endif // UE_OBJECT_PTR_GC_BARRIER
330};
331
332template <typename T>
333struct TPrivateObjectPtr;
334
336{
338 template <typename T>
340 {
341 return Other;
342 }
343
345 template <
346 typename T,
347 typename U
348 UE_REQUIRES(std::is_pointer_v<std::common_type_t<const T*, U>>)
349 >
350 FORCEINLINE std::common_type_t<const T*, U> CoerceToPointer(const U& Other)
351 {
352 return Other;
353 }
354
356 template <
357 typename T,
358 typename U
360 >
361 FORCEINLINE auto CoerceToPointer(const U& Other) -> decltype(Other.Get())
362 {
363 return Other.Get();
364 }
365
366 template <typename T, typename U>
368 {
369 // simple test if Ptr is null (avoids resolving either side)
370 if (!Ptr)
371 {
372 return !Other;
373 }
374
375#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_REMOTE_OBJECT_HANDLE
376 if (Ptr.IsResolved())
377 {
378 return Ptr.GetNoResolveNoCheck() == Other;
379 }
380 else if (!Other) //avoids resolving if Other is null
381 {
382 return false; // from above, we already know that !Ptr is false
383 }
384#endif
385#if UE_WITH_REMOTE_OBJECT_HANDLE
386 // avoids resolving since we can compare against globally unique id
387 return Ptr.GetRemoteId() == FRemoteObjectId(reinterpret_cast<const UObjectBase*>(Other));
388#else
389 return Ptr.GetNoReadNoCheck() == Other;
390#endif
391 }
392
394 template <
395 typename T,
396 typename U,
397 decltype(CoerceToPointer<T>(std::declval<U>()) == std::declval<const T*>())* = nullptr
399 >
400 bool IsObjectPtrEqual(const TObjectPtr<T>& Ptr, const U& Other)
401 {
402 // This function deliberately avoids the tracking code path as we are only doing
403 // a shallow pointer comparison.
404 return IsObjectPtrEqualToRawPtrOfRelatedType<T>(Ptr, ObjectPtr_Private::CoerceToPointer<T>(Other));
405 }
406
408 template <
409 typename T
410#if UE_WITH_OBJECT_HANDLE_TYPE_SAFETY
411 UE_REQUIRES(std::is_same_v<std::remove_const_t<T>, UObject>)
412#endif
413 >
415 {
416 return !ObjectPtr.operator bool();
417 }
418
420 template <
421 typename T
422#if UE_WITH_OBJECT_HANDLE_TYPE_SAFETY
423 UE_REQUIRES(std::is_same_v<std::remove_const_t<T>, UObject>)
424#endif
425 >
426 FORCEINLINE T* Get(const FObjectPtr& ObjectPtr)
427 {
428 return (T*)ObjectPtr.Get();
429 }
430
431#if UE_WITH_OBJECT_HANDLE_TYPE_SAFETY
433 template <
434 typename T
435 UE_REQUIRES(!std::is_same_v<std::remove_const_t<T>, UObject>)
436 >
437 FORCEINLINE bool IsObjectPtrNull(const FObjectPtr& ObjectPtr)
438 {
439 if (!IsObjectHandleTypeSafe(ObjectPtr.GetHandle()))
440 {
441 // Type is unsafe; this pointer will resolve to NULL.
442 return true;
443 }
444
445 return !ObjectPtr.operator bool();
446 }
447
449 template <
450 typename T
451 UE_REQUIRES(!std::is_same_v<std::remove_const_t<T>, UObject>)
452 >
453 FORCEINLINE T* Get(const FObjectPtr& ObjectPtr)
454 {
455 if (!IsObjectHandleTypeSafe(ObjectPtr.GetHandle()))
456 {
457 // Type is unsafe; return NULL without resolving.
458 return nullptr;
459 }
460
461 return (T*)ObjectPtr.Get();
462 }
463#endif
464
465 template <typename T, int = sizeof(T)>
467
468 template <typename T>
470
471 struct Friend;
472};
473
486template <typename T>
488{
489#if !defined(PLATFORM_COMPILER_IWYU) && !defined(UE_HEADER_UNITS)
490 // TObjectPtr should only be used on types T that are EITHER:
491 // - incomplete (ie: forward declared and we have not seen their definition yet)
492 // - complete and derived from UObject
493 // This means that the following are invalid and must fail to compile:
494 // - TObjectPtr<int>
495 // - TObjectPtr<IInterface>
496 static_assert(std::disjunction<std::bool_constant<sizeof(ObjectPtr_Private::ResolveTypeIsComplete<T>(1)) != 2>, std::is_base_of<UObject, T>>::value, "TObjectPtr<T> can only be used with types derived from UObject");
497#endif
498
499public:
500 using ElementType = T;
501
502 [[nodiscard]] constexpr TObjectPtr()
503 : ObjectPtr()
504 {
505 }
506
507#if UE_OBJECT_PTR_GC_BARRIER
516#else
517 [[nodiscard]] TObjectPtr(TObjectPtr<T>&& Other) = default;
518 TObjectPtr(const TObjectPtr<T>& Other) = default;
519#endif // UE_OBJECT_PTR_GC_BARRIER
520
521 [[nodiscard]] explicit constexpr FORCEINLINE TObjectPtr(ENoInit)
523 {
524 }
525
527 : ObjectPtr(nullptr)
528 {
529 }
530
531 [[nodiscard]] explicit FORCEINLINE constexpr TObjectPtr(FObjectPtr ObjPtr)
532 : ObjectPtr(ObjPtr)
533 {
534 }
535
538 {
539 }
540
541 template <
542 typename U
543 UE_REQUIRES(std::is_convertible_v<U*, T*>)
544 >
550
551 template <
552 typename U
553 UE_REQUIRES(!TIsTObjectPtr_V<std::decay_t<U>> && std::is_convertible_v<U, T*>)
554 >
555 [[nodiscard]] constexpr FORCEINLINE TObjectPtr(const U& Object)
557 {
558 }
559
560 UE_DEPRECATED(5.6, "Constructing a TObjectPtr from a reference is deprecated - use a pointer instead.")
565
570
571#if UE_OBJECT_PTR_GC_BARRIER
573 {
574 ObjectPtr = MoveTemp(Other.ObjectPtr);
575 return *this;
576 }
578 {
579 ObjectPtr = Other.ObjectPtr;
580 return *this;
581 }
582#else
584 TObjectPtr<T>& operator=(const TObjectPtr<T>&) = default;
585#endif // UE_OBJECT_PTR_GC_BARRIER
586
588 {
589 ObjectPtr = nullptr;
590 return *this;
591 }
592
593 template <
594 typename U
595 UE_REQUIRES(std::is_convertible_v<U*, T*>)
596 >
598 {
600 ObjectPtr = Other.ObjectPtr;
601 return *this;
602 }
603
604 template <
605 typename U
606 UE_REQUIRES(!TIsTObjectPtr_V<std::decay_t<U>> && std::is_convertible_v<U, T*>)
607 >
609 {
610 ObjectPtr = const_cast<std::remove_const_t<T>*>(ImplicitConv<T*>(Object));
611 return *this;
612 }
613
615 {
616 ObjectPtr = const_cast<UObject*>(PrivatePtr.Pointer);
617 return *this;
618 }
619
620 // Equality/Inequality comparisons against other TObjectPtr
621 template <
622 typename U,
623 typename Base = std::common_type_t<T*, U*>
624 >
626 {
627#if UE_WITH_OBJECT_HANDLE_TYPE_SAFETY
628 // Do a NULL test first before comparing the underlying handles, in case either side is
629 // a non-NULL, but unsafe type pointer (which would equate to NULL when Get() is called).
630 if (ObjectPtr_Private::IsObjectPtrNull<T>(ObjectPtr))
631 {
632 return ObjectPtr_Private::IsObjectPtrNull<U>(Other.ObjectPtr);
633 }
634 else if (ObjectPtr_Private::IsObjectPtrNull<U>(Other.ObjectPtr))
635 {
636 return false;
637 }
638#endif
639 return ObjectPtr == Other.ObjectPtr;
640 }
641
642 // Equality/Inequality comparisons against nullptr
644 {
645 return ObjectPtr_Private::IsObjectPtrNull<T>(ObjectPtr);
646 }
647
648 // Equality/Inequality comparisons against another type that can be implicitly converted to the pointer type kept in a TObjectPtr
649 template <
650 typename U,
651 typename = decltype(ObjectPtr_Private::IsObjectPtrEqual(std::declval<const TObjectPtr<T>&>(), std::declval<const U&>()))
652 >
653 [[nodiscard]] FORCEINLINE bool UEOpEquals(const U& Other) const
654 {
656 }
657
658 // @TODO: OBJPTR: There is a risk that the FObjectPtr is storing a reference to the wrong type. This could
659 // happen if data was serialized at a time when a pointer field was declared to be of type A, but then the declaration
660 // changed and the pointer field is now of type B. Upon deserialization of pre-existing data, we'll be holding
661 // a reference to the wrong type of object which we'll just send back static_casted as the wrong type. Doing
662 // a check or checkSlow here could catch this, but it would be better if the check could happen elsewhere that
663 // isn't called as frequently.
664 [[nodiscard]] FORCEINLINE T* Get() const { return ObjectPtr_Private::Get<T>(ObjectPtr); }
671
677
679 {
680 return ObjectPtr.IsIn(SomeOuter);
681 }
682
683 template <typename U>
685 {
686 return ObjectPtr.IsIn(SomeOuter.ObjectPtr);
687 }
688
689 [[nodiscard]] FORCEINLINE operator T* () const
690 {
691 return Get();
692 }
693 template <typename U>
694 UE_OBJPTR_DEPRECATED(5.0, "Explicit cast to other raw pointer types is deprecated. Please use the Cast API or get the raw pointer with ToRawPtr and cast that instead.")
695 [[nodiscard]] explicit FORCEINLINE operator U* () const
696 {
697 return (U*)Get();
698 }
699 [[nodiscard]] explicit FORCEINLINE operator UPTRINT() const
700 {
701 return (UPTRINT)Get();
702 }
704 {
705 return Get();
706 }
708 {
709 return *Get();
710 }
711
712 UE_OBJPTR_DEPRECATED(5.0, "Conversion to a mutable pointer is deprecated. Please pass a TObjectPtr<T>& instead so that assignment can be tracked accurately.")
713 [[nodiscard]] explicit FORCEINLINE operator T*& ()
714 {
715 return GetInternalRef();
716 }
717
719 {
720 return ObjectPtr_Private::IsObjectPtrNull<T>(ObjectPtr);
721 }
722 [[nodiscard]] explicit FORCEINLINE operator bool() const
723 {
724 return !ObjectPtr_Private::IsObjectPtrNull<T>(ObjectPtr);
725 }
727 {
728 return ObjectPtr.IsResolved();
729 }
731 {
732 return ObjectPtr.IsRemote();
733 }
734 [[nodiscard]] FORCEINLINE FString GetPath() const
735 {
736 return ObjectPtr.GetPath();
737 }
739 {
740 return ObjectPtr.GetPathName();
741 }
743 {
744 return ObjectPtr.GetFName();
745 }
746 [[nodiscard]] FORCEINLINE FString GetName() const
747 {
748 return ObjectPtr.GetName();
749 }
755 {
756 return ObjectPtr.GetHandle();
757 }
758 [[nodiscard]] FORCEINLINE bool IsA(const UClass* SomeBase) const
759 {
760 return ObjectPtr.IsA(SomeBase);
761 }
762 template <typename U>
763 [[nodiscard]] FORCEINLINE bool IsA() const
764 {
765 return ObjectPtr.IsA<U>();
766 }
767
769 {
770 return GetTypeHash(ObjectPtr);
771 }
772
777
779 {
780 return *this;
781 }
782
784 {
785 return *this;
786 }
787
788#if UE_WITH_REMOTE_OBJECT_HANDLE
789 [[nodiscard]] FORCEINLINE FRemoteObjectId GetRemoteId() const
790 {
791 return ObjectPtr.GetRemoteId();
792 }
793#endif
794
796 friend struct FObjectPtr;
797 template <typename U> friend struct TObjectPtr;
798 template <typename U, typename V> friend bool ObjectPtr_Private::IsObjectPtrEqualToRawPtrOfRelatedType(const TObjectPtr<U>& Ptr, const V* Other);
799
800private:
802 FORCEINLINE T* GetNoResolveNoCheck() const { return (T*)(UE::CoreUObject::Private::ReadObjectHandlePointerNoCheck(ObjectPtr.GetHandleRef())); }
803
804 // @TODO: OBJPTR: There is a risk of a gap in access tracking here. The caller may get a mutable pointer, write to it, then
805 // read from it. That last read would happen without an access being recorded. Not sure if there is a good way
806 // to handle this case without forcing the calling code to be modified.
807 FORCEINLINE T*& GetInternalRef()
808 {
809 ObjectPtr_Private::Get<T>(ObjectPtr);
810#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
812#endif
813 return (T*&)ObjectPtr.GetHandleRef();
814 }
815
816 union
817 {
819 // DebugPtr allows for easier dereferencing of a resolved TObjectPtr in watch windows of debuggers. If the address in the pointer
820 // is an odd/uneven number, that means the object reference is unresolved and you will not be able to dereference it successfully.
822 };
823};
824
825// Equals against nullptr to optimize comparing against nullptr as it avoids resolving
826
827template <typename T>
829{
830 typedef T Type;
831};
832template <typename T>
834{
835 typedef T Type;
836};
837
838namespace ObjectPtr_Private
839{
840 template <typename T> struct TRawPointerType { using Type = T; };
841 template <typename T> struct TRawPointerType< TObjectPtr<T>> { using Type = T*; };
842 template <typename T> struct TRawPointerType<const TObjectPtr<T>> { using Type = T*; };
843 template <typename T> struct TRawPointerType< volatile TObjectPtr<T>> { using Type = T*; };
844 template <typename T> struct TRawPointerType<const volatile TObjectPtr<T>> { using Type = T*; };
845 struct Friend
846 {
847 template <typename T>
849 {
850 return GetTypeHash(InObjectPtr.ObjectPtr);
851 }
852
853 template <typename T>
855 {
856 Ar << InObjectPtr.ObjectPtr;
857 return Ar;
858 }
859
860 template <typename T>
865
866 template <typename T>
868 {
870 }
871
872 template <typename T>
877 };
878
879 template <typename T>
881 {
882 public:
883 constexpr TNonAccessTrackedObjectPtr() = default;
884
886 : ObjectPtr{NoInit}
887 {
888 }
889
890 explicit constexpr TNonAccessTrackedObjectPtr(T* Ptr)
891 : ObjectPtr{Ptr}
892 {
893 }
894
895 // Unsafe constructor that doesn't check that the argument really is a T
897 : ObjectPtr{FObjectPtr(Ptr)}
898 {
899 }
900
902 {
903 ObjectPtr = Value;
904 return *this;
905 }
906
907 T* Get() const
908 {
910 }
911
916
917 explicit operator UPTRINT() const
918 {
919 return BitCast<UPTRINT>(Get());
920 }
921
923 {
924 return ObjectPtr;
925 }
926
928 {
929 return ObjectPtr;
930 }
931
932 operator T*() const
933 {
934 return Get();
935 }
936
937 T* operator->() const
938 {
939 return Get();
940 }
941
942 private:
943 TObjectPtr<T> ObjectPtr;
944 };
945}
946
947template <typename T>
952
953template <typename T>
958
959template <typename T>
964
965template <typename T>
967
968template <typename T>
970{
971public:
973
974private:
976 explicit TPrivateObjectPtr(const UObject* InPointer)
977 : Pointer(InPointer)
978 {
979 }
980
981 const UObject* Pointer;
982 friend struct TObjectPtr<T>;
984};
985
987template <typename T>
992
993template <typename T>
995{
996 return TObjectPtr<T>{Obj};
997}
998
999template <typename T>
1001{
1002 // NOTE: This is specifically not getting a reference to the internal pointer.
1003 return Ptr.Get();
1004}
1005
1006template <typename T>
1008{
1009 return Ptr;
1010}
1011
1012#if !UE_DEPRECATE_MUTABLE_TOBJECTPTR
1013template <typename T, SIZE_T Size>
1014UE_DEPRECATED(5.6, "Mutable ToRawPtrArrayUnsafe() is deprecated. Use MutableView() or TArray<TObjectPtr<...>> instead.")
1015[[nodiscard]] FORCEINLINE T**
1017{
1018#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1019 for (TObjectPtr<T>& Item : ArrayOfPtr)
1020 {
1021 // NOTE: Relying on the fact that the TObjectPtr will cache the resolved pointer in place after calling Get.
1022 (void)Item.Get();
1023 check(Item.IsResolved());
1024 }
1025#endif
1026
1027 return reinterpret_cast<T**>(ArrayOfPtr);
1028}
1029#endif
1030
1031template <typename T, SIZE_T Size>
1032[[nodiscard]] FORCEINLINE const T* const *
1034{
1035#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1037 TypeCompat::ReinterpretRangeContiguous(&ArrayOfPtr[0], &ArrayOfPtr[Size], Size);
1038#endif
1039
1040 return reinterpret_cast<const T* const *>(ArrayOfPtr);
1041}
1042
1043template <typename T>
1045{
1046 return ArrayOfPtr;
1047}
1048
1050template <
1051 typename ArrayType,
1052 typename ArrayTypeNoRef = std::remove_reference_t<ArrayType>
1054>
1055#if UE_DEPRECATE_MUTABLE_TOBJECTPTR
1056[[nodiscard]] const auto&
1057#else
1058UE_DEPRECATED(5.6, "Mutable ToRawPtrTArrayUnsafe() is deprecated. Use MutableView() or TArray<TObjectPtr<...>> instead.")
1059[[nodiscard]] decltype(auto)
1060#endif
1061ToRawPtrTArrayUnsafe(ArrayType&& Array)
1062{
1063 using ArrayElementType = typename ArrayTypeNoRef::ElementType;
1064 using ArrayAllocatorType = typename ArrayTypeNoRef::AllocatorType;
1069
1070#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1072 TypeCompat::ReinterpretRange(Array.begin(), Array.end());
1073#endif
1074
1076}
1078
1079inline constexpr auto TContainerElementTypeCompatibility_DefaultOperatorFunc = [](auto& InIt) -> decltype(auto) { return *InIt; };
1080
1081template <typename T>
1083{
1086
1088 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
1090 {
1091#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1092 while (Iter != IterEnd)
1093 {
1094 (void)Operator(Iter).Get();
1095 check(Operator(Iter).IsResolved());
1096 ++Iter;
1097 }
1098#endif
1099 }
1100
1102 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
1104 {
1105#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1106 const TObjectPtr<T>* Begin = &*Iter;
1107 while (Iter != IterEnd)
1108 {
1109 auto& Ptr = Operator(Iter);
1110 const FObjectPtr& ObjPtr = reinterpret_cast<const FObjectPtr&>(Ptr);
1112 check(ObjPtr.IsResolved());
1113 ++Iter;
1114 }
1115 const UObject* const* ObjPtr = reinterpret_cast<const UObject* const*>(Begin);
1117#endif
1118 }
1119
1120 UE_OBJPTR_DEPRECATED(5.0, "Copying ranges of one type to another type is deprecated.")
1122};
1123
1124template <typename T>
1126{
1127 typedef T* const ReinterpretType;
1128 typedef T* const CopyFromOtherType;
1129
1131 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
1133 {
1134#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1135 while (Iter != IterEnd)
1136 {
1137 Operator(Iter).Get();
1138 check(Operator(Iter).IsResolved());
1139 ++Iter;
1140 }
1141#endif
1142 }
1143
1145 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
1147 {
1148#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1149 const TObjectPtr<T>* Begin = &*Iter;
1150 while (Iter != IterEnd)
1151 {
1152 auto& Ptr = Operator(Iter);
1153 const FObjectPtr& ObjPtr = reinterpret_cast<const FObjectPtr&>(Ptr);
1155 check(ObjPtr.IsResolved());
1156 ++Iter;
1157 }
1158 const UObject* const* ObjPtr = reinterpret_cast<const UObject* const*>(Begin);
1160#endif
1161 }
1162
1163 UE_OBJPTR_DEPRECATED(5.0, "Copying ranges of one type to another type is deprecated.")
1165};
1166
1167// Trait which allows TObjectPtr to be default constructed by memsetting to zero.
1168template <typename T>
1170{
1171 enum { Value = true };
1172};
1173
1174// Trait which allows TObjectPtr to be memcpy'able from pointers.
1175template <typename T>
1180
1181template <typename T, class PREDICATE_CLASS>
1195
1196template <typename T>
1197struct TCallTraits<TObjectPtr<T>> : public TCallTraitsBase<TObjectPtr<T>>
1198{
1200};
1201
1202
1203template <typename T>
1205{
1206#if UE_WITH_REMOTE_OBJECT_HANDLE
1207 if (Ptr.IsRemote())
1208 {
1209 return TWeakObjectPtr<T>(Ptr.GetRemoteId());
1210 }
1211 else
1212#endif
1213 {
1214 return TWeakObjectPtr<T>(Ptr);
1215 }
1216}
1217
1219{
1220 return *reinterpret_cast<TObjectPtr<UObject>*>(this);
1221}
1222
1224{
1225 return *reinterpret_cast<const TObjectPtr<UObject>*>(this);
1226}
1227
1229template <typename T>
1230inline void Swap(TObjectPtr<T>& A, T*& B)
1231{
1232 Swap(static_cast<T*&>(MutableView(A)), B);
1233}
1234template <typename T>
1235inline void Swap(T*& A, TObjectPtr<T>& B)
1236{
1237 Swap(A, static_cast<T*&>(MutableView(B)));
1238}
1239
1241#if !UE_DEPRECATE_MUTABLE_TOBJECTPTR
1242UE_DEPRECATED(5.6, "Swap between TObjectPtr arrays and raw pointer arrays is deprecated. Swap TArray<TObjectPtr<...>> values instead.")
1245{
1247}
1248template <typename T>
1250{
1252}
1253#endif
1254
1256template <typename T>
1257inline void Exchange(TObjectPtr<T>& A, T*& B)
1258{
1259 Swap(static_cast<T*&>(MutableView(A)), B);
1260}
1261template <typename T>
1262inline void Exchange(T*& A, TObjectPtr<T>& B)
1263{
1264 Swap(A, static_cast<T*&>(MutableView(B)));
1265}
1266
1267#if !UE_DEPRECATE_MUTABLE_TOBJECTPTR
1269UE_DEPRECATED(5.6, "Exchange between TObjectPtr arrays and raw pointer arrays is deprecated. Exchange TArray<TObjectPtr<...>> values instead.")
1272{
1274}
1275template <typename T>
1277{
1279}
1280#endif
1281
1285template <typename T>
1287{
1288 T* TestPtr = ToRawPtr(Test);
1289 return IsValid(TestPtr) ? TestPtr : nullptr;
1290}
1291
1292//------------------------------------------------------------------------------
1293// Suppose you want to have a function that outputs an array of either T*'s or TObjectPtr<T>'s
1294// this template will make that possible to encode,
1295//
1296// template<typename InstanceClass>
1297// void GetItemInstances(TArray<InstanceClass>& OutInstances) const
1298// {
1299// static_assert(TIsPointerOrObjectPtrToBaseOf<InstanceClass, UBaseClass>::Value, "Output array must contain pointers or TObjectPtrs to a base of UBaseClass");
1300// }
1301//------------------------------------------------------------------------------
1302
1303template <typename T, typename DerivedType>
1305{
1306 enum { Value = false };
1307};
1308
1309template <typename T, typename DerivedType>
1311{
1312 enum { Value = std::is_base_of_v<DerivedType, T> };
1313};
1314
1315template <typename T, typename DerivedType>
1317{
1318 enum { Value = std::is_base_of_v<DerivedType, T> };
1319};
1320
1321template <typename T, typename DerivedType>
1326
1327//------------------------------------------------------------------------------
1328// Suppose now that you have a templated function that takes in an array of either
1329// UBaseClass*'s or TObjectPtr<UBaseClass>'s, and you need to use that inner UBaseClass type
1330// for coding,
1331//
1332// This is how you can refer to that inner class. Where InstanceClass is the template
1333// argument for where TIsPointerOrObjectPtrToBaseOf is used,
1334//
1335// TPointedToType<InstanceClass>* Thing = new TPointedToType<InstanceClass>();
1336//------------------------------------------------------------------------------
1337
1338template <typename T>
1340
1341template <typename T>
1343{
1344 using Type = T;
1345};
1346
1347template <typename T>
1349{
1350 using Type = T;
1351};
1352
1353template <typename T>
1355
1356//------------------------------------------------------------------------------
1357
1358namespace UE::Core::Private // private facilities; not for direct use
1359{
1360 template <typename T>
1362 {
1363 using Type = T;
1364 static FORCEINLINE void PerformDecayActions(const T&) { /* nb: intentionally empty */ }
1365 };
1366
1367 template <typename T>
1369 {
1370 using Type = T*;
1371
1373 {
1374#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1375 (void)Value.Get();
1376 check(Value.IsResolved());
1377#endif
1378 }
1379 };
1380
1381 template <typename T>
1383 {
1385
1387 {
1388 for (const auto& V : Value)
1389 {
1391 }
1392 }
1393 };
1394
1395 template <typename K, typename V>
1409
1410 template <typename T>
1412 {
1414
1416 {
1417 for (const auto& V : Value)
1418 {
1420 }
1421 }
1422 };
1423
1424 template <typename T>
1426 {
1428
1430 {
1431#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
1432 (void)Value.GetRef().Get();
1433#endif
1434 }
1435 };
1436
1437 template <typename T>
1439 {
1440 using Type = T;
1441 };
1442
1443 template <typename T>
1445 {
1447 };
1448
1449 template <typename T>
1454
1455 template <typename T>
1460
1461 template <typename T>
1466
1467 template <typename K, typename V>
1472
1473 namespace Unsafe
1474 {
1475 template <typename T,
1477 typename U = typename DecayTraits::Type>
1478 [[nodiscard]] U& Decay(T& A)
1479 {
1480 DecayTraits::PerformDecayActions(A);
1481 return reinterpret_cast<U&>(A);
1482 }
1483 }
1484
1485 template <typename T, typename ViewType>
1487 {
1488 static_assert(sizeof(T) == 0, "TMutableView not supported for this type. (Should it be?)");
1489 };
1490
1491 template <typename T, typename ViewType>
1492 struct TMutableViewTraits<TObjectPtr<T>, ViewType>
1493 {
1494 static void Close(ViewType& View)
1495 {
1496#if UE_OBJECT_PTR_GC_BARRIER
1498 {
1500 }
1501#endif // UE_OBJECT_PTR_GC_BARRIER
1502 }
1503 };
1504
1505 template <typename T, typename ViewType>
1507 {
1508 static void Close(ViewType& View)
1509 {
1510#if UE_OBJECT_PTR_GC_BARRIER
1512 {
1513 const UObject* const* Data = reinterpret_cast<const UObject* const*>(View.GetData());
1514 for (int32 Index = 0; Index < View.Num(); ++Index)
1515 {
1516 if (Data[Index])
1517 {
1519 }
1520 }
1521 }
1522#endif // UE_OBJECT_PTR_GC_BARRIER
1523 }
1524 };
1525
1526 template <typename V, typename ViewType>
1527 struct TMutableViewTraits<TSet<TObjectPtr<V>>, ViewType>
1528 {
1529 static void Close(ViewType& View)
1530 {
1531#if UE_OBJECT_PTR_GC_BARRIER
1533 {
1534 for (const typename ViewType::ElementType& Element : View)
1535 {
1536 if (Element)
1537 {
1538 UE::GC::MarkAsReachable(Element);
1539 }
1540 }
1541 }
1542#endif // UE_OBJECT_PTR_GC_BARRIER
1543 }
1544 };
1545
1546 template <typename K, typename V, typename ViewType>
1547 struct TMutableViewTraits<TMap<K, V>, ViewType>
1548 {
1549 static void Close(ViewType& View)
1550 {
1551#if UE_OBJECT_PTR_GC_BARRIER
1552 static constexpr bool bKeyReference = TIsTObjectPtr_V<K>;
1553 static constexpr bool bValueReference = TIsTObjectPtr_V<V>;
1554 static_assert(bKeyReference || bValueReference);
1556 {
1557 for (const typename ViewType::ElementType& Pair : View)
1558 {
1559 if constexpr (bKeyReference)
1560 {
1561 if (Pair.Key)
1562 {
1563 UE::GC::MarkAsReachable(Pair.Key);
1564 }
1565 }
1566 if constexpr (bValueReference)
1567 {
1568 if (Pair.Value)
1569 {
1570 UE::GC::MarkAsReachable(Pair.Value);
1571 }
1572 }
1573 }
1574 }
1575#endif // UE_OBJECT_PTR_GC_BARRIER
1576 }
1577 };
1578
1579 template <typename T>
1581 {
1582 public:
1585
1586 explicit TMutableView(T& Value)
1587 : View{&Unsafe::Decay(Value)}
1588 {
1589 }
1590
1592 {
1593 TraitType::Close(*View);
1594 }
1595
1596 TMutableView(const TMutableView&) = delete;
1600
1601 operator ViewType&() const
1602 {
1603 return *View;
1604 }
1605
1606 private:
1607 ViewType* View;
1608 };
1609
1610 // nb: TMaybeObjectPtr class exists as a temporary compatibility shim with existing code;
1611 // do not use in new code. it allows code that holds pointers to abstract classes that
1612 // might point to instances that also subclass UObject to properly interact with
1613 // garbage collection.
1614 template <typename T>
1616 {
1617 static_assert(!std::is_convertible_v<T, const UObjectBase*>, "TMaybeObjectPtr's type argument shouldn't be a subclass of UObjectBase");
1618
1619 public:
1620 TMaybeObjectPtr() = default;
1621
1622 explicit TMaybeObjectPtr(T* P)
1623 : Ptr{P}
1624 {
1625 ConditionallyMarkAsReachable();
1626 }
1627
1629 : TMaybeObjectPtr{Other.Ptr}
1630 {
1631 }
1632
1637
1639 {
1640 return *this = Other.Ptr;
1641 }
1642
1644 {
1645 return *this = Other;
1646 }
1647
1649 {
1650 Ptr = P;
1651 ConditionallyMarkAsReachable();
1652 return *this;
1653 }
1654
1655 operator T*() const
1656 {
1657 return Ptr;
1658 }
1659
1660 void AddReferencedObject(FReferenceCollector& Collector, UObject* ReferencingObject)
1661 {
1662 if (const UObject* Obj = Cast<UObject>(Ptr))
1663 {
1664 TObjectPtr<UObject> ObjectPtr{const_cast<UObject*>(Obj)};
1665 Collector.AddReferencedObject(ObjectPtr, ReferencingObject);
1666 if (!ObjectPtr)
1667 {
1668 Ptr = nullptr;
1669 }
1670 }
1671 }
1672
1673 private:
1674 FORCEINLINE void ConditionallyMarkAsReachable() const
1675 {
1677 {
1679 }
1680 }
1681
1682 T* Ptr{};
1683 };
1684}
1685
1686/*
1687 MutableView: safely obtain temporary mutable access to a TObjectPtr's
1688 underlying storage.
1689
1690 // Basic Usage:
1691
1692 void MutatingFunc(TArray<UObject*>& MutableArray);
1693
1694 TArray<TObjectPtr<UObject>> Array;
1695 MutatingFunc(Array); // unsafe; compile error
1696
1697 MutatingFunc(MutableView(Array)); // ok; Array will safely "catch up" on TObjectPtr
1698 // semantics when MutatingFunc returns.
1699
1700 // it's generally preferable to pass references around (to avoid nullptr),
1701 // but for compat with existing functions that take a pointer:
1702
1703 void NeedsAPointer(TArray<UObject*>* MutableArrayPtr);
1704 NeedsAPointer(ToRawPtr(MutableView(Array)));
1705
1706 // Scoped Usage:
1707
1708 TObjectPtr<UObject> MyPtr;
1709 {
1710 auto MyScopedView = MutableView(MyPtr);
1711 UObject*& MyRawPtrRef = MyScopedView; // ok
1712
1713 UObject*& MyHardToFindBug = MutableView(MyPtr); // not ok
1714 }
1715*/
1716
1717template <typename T>
1718[[nodiscard]] decltype(auto) MutableView(T& A)
1719{
1721}
1722
1723template <typename T>
1725{
1726 typename std::remove_reference_t<decltype(X)>::ViewType& Ref = X;
1727 return &Ref;
1728}
1729
1730/*
1731 whenever const access to the underlying storage of a TObjectPtr<...> (or a container of them)
1732 is needed, use Decay, eg:
1733
1734 TMap<int, TArray<TObjectPtr<UObject>>> MyContainer;
1735
1736 void MyFunc(const TMap<int, TArray<UObject*>>&);
1737
1738 MyFunc(MyContainer); // compile error
1739 MyFunc(ObjectPtrDecay(MyContainer)); // ok
1740*/
1741template <typename T,
1743 typename U = typename DecayTraits::Type>
1744[[nodiscard]] const U& ObjectPtrDecay(const T& Value)
1745{
1746 DecayTraits::PerformDecayActions(Value);
1747 return reinterpret_cast<const U&>(Value);
1748}
1749
1750/*
1751 "Wrap" is the opposite of "Decay"
1752*/
1753template <typename T,
1756{
1757 return reinterpret_cast<U&>(Value);
1758}
1759
1760template <typename T>
1762
1763template <typename T,
1765[[nodiscard]] const U& ObjectPtrWrap(const T& Value)
1766{
1767 return reinterpret_cast<const U&>(Value);
1768}
1769
1770/* cast utilities; best avoided, use mostly for compatibility with existing code */
1771template <typename To, typename From>
1773{
1774 return static_cast<To*>(P.Get());
1775}
1776
1777template <typename T>
1778[[nodiscard]] FORCEINLINE decltype(auto) ConstCast(const TObjectPtr<T>& P)
1779{
1780 return reinterpret_cast<TObjectPtr<std::remove_cv_t<T>>&>(const_cast<TObjectPtr<T>&>(P));
1781}
1782
1783
1784template<typename ObjectType>
1785class TNonNullPtr<TObjectPtr<ObjectType>>
1786{
1787public:
1788
1790 : Object(nullptr)
1791 {
1792 }
1793
1798 {
1799 // Essentially static_assert(false), but this way prevents GCC/Clang from crying wolf by merely inspecting the function body
1800 static_assert(sizeof(ObjectType) == 0, "Tried to initialize TNonNullPtr with a null pointer!");
1801 }
1802
1807 : Object(InObject)
1808 {
1809 ensureAlwaysMsgf(InObject, TEXT("Tried to initialize TNonNullPtr with a null pointer!"));
1810 }
1811
1815 template <
1816 typename OtherObjectType
1817 UE_REQUIRES(std::is_convertible_v<OtherObjectType*, ObjectType*>)
1818 >
1820 : Object(Other.Object)
1821 {
1822 }
1823
1828 {
1829 // Essentially static_assert(false), but this way prevents GCC/Clang from crying wolf by merely inspecting the function body
1830 static_assert(sizeof(ObjectType) == 0, "Tried to assign a null pointer to a TNonNullPtr!");
1831 return *this;
1832 }
1833
1837 FORCEINLINE TNonNullPtr& operator=(ObjectType* InObject)
1838 {
1839 ensureMsgf(InObject, TEXT("Tried to assign a null pointer to a TNonNullPtr!"));
1840 Object = InObject;
1841 return *this;
1842 }
1843
1847 template <
1848 typename OtherObjectType
1849 UE_REQUIRES(std::is_convertible_v<OtherObjectType*, ObjectType*>)
1850 >
1852 {
1853 Object = Other.Object;
1854 return *this;
1855 }
1856
1860 [[nodiscard]] FORCEINLINE operator ObjectType*() const
1861 {
1862 ensureMsgf(Object, TEXT("Tried to access null pointer!"));
1863 return Object;
1864 }
1865
1869 [[nodiscard]] FORCEINLINE ObjectType* Get() const
1870 {
1871 ensureMsgf(Object, TEXT("Tried to access null pointer!"));
1872 return Object;
1873 }
1874
1878 [[nodiscard]] FORCEINLINE ObjectType& operator*() const
1879 {
1880 ensureMsgf(Object, TEXT("Tried to access null pointer!"));
1881 return *Object;
1882 }
1883
1887 [[nodiscard]] FORCEINLINE ObjectType* operator->() const
1888 {
1889 ensureMsgf(Object, TEXT("Tried to access null pointer!"));
1890 return Object;
1891 }
1892
1894 {
1895 ensureMsgf(Object, TEXT("Tried to access null pointer!"));
1896 return Object;
1897 }
1898
1900 {
1901 ensureMsgf(Object, TEXT("Tried to access null pointer!"));
1902 return Object;
1903 }
1904
1906 {
1907 return Object != nullptr;
1908 }
1909
1913 explicit operator bool() const = delete;
1914
1915private:
1917 {
1918 return GetTypeHash(InPtr.Object);
1919 }
1920
1923};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define ensureAlwaysMsgf(InExpression, InFormat,...)
Definition AssertionMacros.h:467
#define check(expr)
Definition AssertionMacros.h:314
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
typename TCopyQualifiersFromTo< From, To >::Type TCopyQualifiersFromTo_T
Definition CopyQualifiersFromTo.h:17
ENoInit
Definition CoreMiscDefines.h:158
@ NoInit
Definition CoreMiscDefines.h:158
#define UE_INTERNAL
Definition CoreMiscDefines.h:345
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
EConstEval
Definition CoreMiscDefines.h:161
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TYPE_OF_NULLPTR TYPE_OF_NULLPTR
The type of the C++ nullptr keyword.
Definition Platform.h:1157
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::UPTRINT UPTRINT
An unsigned integer the same size as a pointer.
Definition Platform.h:1146
#define UE_IF_NOT_CONSTEVAL
Definition Platform.h:787
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
constexpr bool TIsTObjectPtr_V
Definition IsTObjectPtr.h:8
const bool
Definition NetworkReplayStreaming.h:178
EDefaultConstructNonNullPtr
Definition NonNullPointer.h:16
EObjectFullNameFlags
Definition ObjectFwd.h:12
bool IsObjectHandleNull(FObjectHandle Handle)
Definition ObjectHandle.h:194
bool IsObjectHandleTypeSafe(FObjectHandle Handle)
Definition ObjectHandle.h:245
bool IsObjectHandleResolved(FObjectHandle Handle)
Definition ObjectHandle.h:209
FORCEINLINE FArchive & operator<<(FArchive &Ar, TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:954
FORCEINLINE T ** ToRawPtrArrayUnsafe(T **ArrayOfPtr)
Definition ObjectPtr.h:1044
PRAGMA_ENABLE_DEPRECATION_WARNINGS constexpr auto TContainerElementTypeCompatibility_DefaultOperatorFunc
Definition ObjectPtr.h:1079
T * GetValid(const TObjectPtr< T > &Test)
Definition ObjectPtr.h:1286
TObjectPtr< T > ToObjectPtr(T *Obj)
Definition ObjectPtr.h:994
#define UE_OBJECT_PTR_GC_BARRIER
Definition ObjectPtr.h:24
void Exchange(TObjectPtr< T > &A, T *&B)
Definition ObjectPtr.h:1257
FORCEINLINE To * StaticCastPtr(const TObjectPtr< From > &P)
Definition ObjectPtr.h:1772
FORCEINLINE uint32 GetTypeHash(const TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:948
FORCEINLINE const T *const * ToRawPtrArray(const TObjectPtr< T >(&ArrayOfPtr)[Size])
Definition ObjectPtr.h:1033
typename TPointedToTypeImpl< T >::Type TPointedToType
Definition ObjectPtr.h:1354
FORCEINLINE TWeakObjectPtr< T > MakeWeakObjectPtr(TObjectPtr< T > Ptr)
Definition ObjectPtr.h:1204
FORCEINLINE decltype(auto) ConstCast(const TObjectPtr< T > &P)
Definition ObjectPtr.h:1778
const U & ObjectPtrDecay(const T &Value)
Definition ObjectPtr.h:1744
decltype(auto) MutableView(T &A)
Definition ObjectPtr.h:1718
#define UE_OBJPTR_DEPRECATED(Version, Message)
Definition ObjectPtr.h:20
U & ObjectPtrWrap(T &Value)
Definition ObjectPtr.h:1755
typename UE::Core::Private::TObjectPtrWrapTypeOf< T >::Type TObjectPtrWrapTypeOf
Definition ObjectPtr.h:1761
FORCEINLINE T * ToRawPtr(const TObjectPtr< T > &Ptr)
Definition ObjectPtr.h:1000
TPrivateObjectPtr< T > MakeObjectPtrUnsafe(const UObject *Obj)
Definition ObjectPtr.h:988
#define IWYU_MARKUP_IMPLICIT_CAST(From, To)
Definition PlatformMisc.h:251
#define UE_REQUIRES(...)
Definition Requires.h:86
UE_REWRITE constexpr T ImplicitConv(typename TIdentity< T >::Type Obj)
Definition UnrealTemplate.h:743
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition CoreUObject.Build.cs:7
Definition Archive.h:1208
Definition NameTypes.h:617
CORE_API FString ToString() const
Definition UnrealNames.cpp:3537
Definition UObjectGlobals.h:2492
Definition StructuredArchiveSlots.h:52
constexpr TNonAccessTrackedObjectPtr(T *Ptr)
Definition ObjectPtr.h:890
UE_INTERNAL T * GetNoResolve() const
Definition ObjectPtr.h:912
consteval TNonAccessTrackedObjectPtr(EConstEval, UObject *Ptr)
Definition ObjectPtr.h:896
const TObjectPtr< T > & GetAccessTrackedObjectPtr() const
Definition ObjectPtr.h:927
T * Get() const
Definition ObjectPtr.h:907
TObjectPtr< T > & GetAccessTrackedObjectPtr()
Definition ObjectPtr.h:922
TNonAccessTrackedObjectPtr & operator=(T *Value)
Definition ObjectPtr.h:901
T * operator->() const
Definition ObjectPtr.h:937
TNonAccessTrackedObjectPtr(ENoInit)
Definition ObjectPtr.h:885
Definition ArrayView.h:139
Definition Array.h:670
Definition UnrealString.h.inl:34
FORCEINLINE TNonNullPtr(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:1797
FORCEINLINE TNonNullPtr(const TNonNullPtr< OtherObjectType > &Other)
Definition ObjectPtr.h:1819
FORCEINLINE ObjectType & operator*() const
Definition ObjectPtr.h:1878
FORCEINLINE ObjectType * operator->() const
Definition ObjectPtr.h:1887
FORCEINLINE TNonNullPtr & operator=(const TNonNullPtr< OtherObjectType > &Other)
Definition ObjectPtr.h:1851
friend FORCEINLINE uint32 GetTypeHash(const TNonNullPtr &InPtr)
Definition ObjectPtr.h:1916
FORCEINLINE const TObjectPtr< ObjectType > & GetRef() const
Definition ObjectPtr.h:1893
FORCEINLINE TNonNullPtr & operator=(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:1827
FORCEINLINE ObjectType * Get() const
Definition ObjectPtr.h:1869
FORCEINLINE TObjectPtr< ObjectType > & GetRef()
Definition ObjectPtr.h:1899
FORCEINLINE TNonNullPtr(EDefaultConstructNonNullPtr)
Definition ObjectPtr.h:1789
FORCEINLINE TNonNullPtr(TObjectPtr< ObjectType > InObject)
Definition ObjectPtr.h:1806
FORCEINLINE bool IsInitialized() const
Definition ObjectPtr.h:1905
FORCEINLINE TNonNullPtr & operator=(ObjectType *InObject)
Definition ObjectPtr.h:1837
Definition NonNullPointer.h:23
friend UE_FORCEINLINE_HINT uint32 GetTypeHash(const TNonNullPtr &InPtr)
Definition NonNullPointer.h:247
Definition Class.h:3793
Definition ObjectPtr.h:1616
void AddReferencedObject(FReferenceCollector &Collector, UObject *ReferencingObject)
Definition ObjectPtr.h:1660
TMaybeObjectPtr & operator=(const TMaybeObjectPtr &Other)
Definition ObjectPtr.h:1638
TMaybeObjectPtr & operator=(TMaybeObjectPtr &&Other)
Definition ObjectPtr.h:1643
TMaybeObjectPtr & operator=(T *P)
Definition ObjectPtr.h:1648
TMaybeObjectPtr(const TMaybeObjectPtr &Other)
Definition ObjectPtr.h:1628
TMaybeObjectPtr(TMaybeObjectPtr &&Other)
Definition ObjectPtr.h:1633
TMaybeObjectPtr(T *P)
Definition ObjectPtr.h:1622
Definition ObjectPtr.h:1581
TMutableView & operator=(TMutableView &&)=delete
TMutableView(TMutableView &&)=delete
~TMutableView()
Definition ObjectPtr.h:1591
TMutableView & operator=(const TMutableView &)=delete
typename TObjectPtrDecayTypeOf< T >::Type ViewType
Definition ObjectPtr.h:1583
TMutableView(const TMutableView &)=delete
TMutableView(T &Value)
Definition ObjectPtr.h:1586
Definition UObjectBase.h:59
Definition Object.h:95
Definition ObjectPtr.h:336
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
bool IsObjectPtrEqual(const TObjectPtr< T > &Ptr, const U &Other)
Definition ObjectPtr.h:400
char(& ResolveTypeIsComplete(int))[2]
bool IsObjectPtrEqualToRawPtrOfRelatedType(const TObjectPtr< T > &Ptr, const U *Other)
Definition ObjectPtr.h:367
FORCEINLINE bool IsObjectPtrNull(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:414
FORCEINLINE const T * CoerceToPointer(const T *Other)
Definition ObjectPtr.h:339
Definition OverriddenPropertySet.cpp:45
Definition TestUtils.cpp:8
UObject * ReadObjectHandlePointerNoCheck(FObjectHandle Handle)
Definition ObjectHandle.h:599
constexpr FObjectHandle MakeObjectHandle(UObject *Object)
these functions are always defined regardless of UE_WITH_OBJECT_HANDLE_LATE_RESOLVE value
Definition ObjectHandle.h:435
UObject * NoResolveObjectHandleNoRead(const FObjectHandle &Handle)
Definition ObjectHandle.h:550
UObject * ResolveObjectHandleNoReadNoCheck(FObjectHandle &Handle)
Definition ObjectHandle.h:564
UObject * ResolveObjectHandleNoRead(FObjectHandle &Handle)
Definition ObjectHandle.h:502
FString GetPathName(const UObject *Obj, const UObject *StopOuter)
Definition ObjectFwd.cpp:28
UObject * GetOuter(const UObject *Obj)
Definition ObjectFwd.cpp:18
FString GetFullName(const UObject *Obj, const UObject *StopOuter, EObjectFullNameFlags Flags)
Definition ObjectFwd.cpp:38
UObject * ResolveObjectHandle(FObjectHandle &Handle)
Definition ObjectHandle.h:441
FName GetFName(const UObject *Obj)
Definition ObjectFwd.cpp:13
UClass * ResolveObjectHandleClass(FObjectHandle Handle)
Definition ObjectHandle.h:462
bool IsIn(const UObject *Obj, const UObject *SomeOuter)
Definition ObjectFwd.cpp:23
void OnHandleRead(const UObject *Object)
Definition ObjectHandleTracking.h:131
UPackage * GetPackage(const UObject *Obj)
Definition ObjectFwd.cpp:33
U & Decay(T &A)
Definition ObjectPtr.h:1478
implementation
Definition PlayInEditorLoadingScope.h:8
bool GIsIncrementalReachabilityPending
Definition GarbageCollection.cpp:620
void MarkAsReachable(const UObject *Obj)
Definition GarbageCollection.cpp:603
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition ObjectPtr.h:55
FORCEINLINE UObject * Get() const
Definition ObjectPtr.h:104
FORCEINLINE FObjectHandle & GetHandleRef() const
Definition ObjectPtr.h:272
bool IsIn(FObjectPtr SomeOuter) const
Definition ObjectPtr.h:252
FString GetPath() const
Definition ObjectPtr.h:196
FObjectPtr GetPackage() const
Definition ObjectPtr.h:246
FObjectPtr GetOuter() const
Definition ObjectPtr.h:240
FORCEINLINE TObjectPtr< UObject > & ToTObjectPtr()
Definition ObjectPtr.h:1218
FORCEINLINE FObjectPtr(FRemoteObjectId ObjectId)
Definition ObjectPtr.h:95
constexpr FObjectPtr(const FObjectPtr &InOther)
Definition ObjectPtr.h:122
FORCEINLINE FRemoteObjectId GetRemoteId() const
Definition ObjectPtr.h:282
FORCEINLINE bool IsRemote() const
Definition ObjectPtr.h:192
COREUOBJECT_API bool IsA(const UClass *SomeBase) const
Definition ObjectPtr.cpp:252
FObjectPtr & operator=(const FObjectPtr &InOther)
Definition ObjectPtr.h:135
FObjectPtr & operator=(FObjectPtr &&InOther)
Definition ObjectPtr.h:128
UObject * DebugPtr
Definition ObjectPtr.h:302
FObjectPtr & operator=(UObject *Other)
Definition ObjectPtr.h:148
FObjectHandle Handle
Definition ObjectPtr.h:299
FORCEINLINE bool IsResolved() const
Definition ObjectPtr.h:186
FORCEINLINE UClass * GetClass() const
Definition ObjectPtr.h:109
FORCEINLINE constexpr FObjectPtr(UObject *Object)
Definition ObjectPtr.h:71
FORCEINLINE FObjectHandle GetHandle() const
Definition ObjectPtr.h:271
FORCEINLINE bool operator!() const
Definition ObjectPtr.h:183
FORCEINLINE bool IsA() const
Definition ObjectPtr.h:277
FORCEINLINE constexpr FObjectPtr(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:66
FName GetFName() const
Definition ObjectPtr.h:229
constexpr FObjectPtr(FObjectPtr &&InOther)
Definition ObjectPtr.h:116
friend FORCEINLINE uint32 GetTypeHash(const FObjectPtr &Object)
Definition ObjectPtr.h:292
constexpr FObjectPtr(ENoInit)
Definition ObjectPtr.h:62
FORCEINLINE bool UEOpEquals(const FObjectPtr &Other) const
Definition ObjectPtr.h:170
constexpr FObjectPtr()
Definition ObjectPtr.h:57
FString GetName() const
Definition ObjectPtr.h:235
FORCEINLINE FObjectPtr(void *IncompleteObject)
Definition ObjectPtr.h:80
FString GetFullName(EObjectFullNameFlags Flags=EObjectFullNameFlags::None) const
Definition ObjectPtr.h:264
FString GetPathName() const
Definition ObjectPtr.h:223
FORCEINLINE UObject * operator->() const
Definition ObjectPtr.h:180
FORCEINLINE UObject & operator*() const
Definition ObjectPtr.h:181
FObjectPtr & operator=(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:164
Definition RemoteObjectTypes.h:212
Definition ObjectPtr.h:846
static FORCEINLINE uint32 GetPtrTypeHash(const TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:848
static FORCEINLINE FArchive & Serialize(FArchive &Ar, TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:854
static FORCEINLINE T * NoAccessTrackingGetNoResolve(const TObjectPtr< T > &Ptr)
Definition ObjectPtr.h:873
static FORCEINLINE void SerializePtrStructured(FStructuredArchiveSlot Slot, TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:861
static FORCEINLINE T * NoAccessTrackingGet(const TObjectPtr< T > &Ptr)
Definition ObjectPtr.h:867
Definition ObjectPtr.h:840
T Type
Definition ObjectPtr.h:840
Definition UnrealTypeTraits.h:267
Definition UnrealTypeTraits.h:229
typename TCallTraitsParamTypeHelper< const TObjectPtr< const T >, true >::ConstParamType ConstPointerType
Definition ObjectPtr.h:1199
Definition UnrealTypeTraits.h:283
static void ReinterpretRange(IterBeginType Iter, IterEndType IterEnd, OperatorType Operator=TContainerElementTypeCompatibility_DefaultOperatorFunc)
Definition ObjectPtr.h:1089
static void ReinterpretRangeContiguous(IterBeginType Iter, IterEndType IterEnd, SizeType Size, OperatorType Operator=TContainerElementTypeCompatibility_DefaultOperatorFunc)
Definition ObjectPtr.h:1103
T * CopyFromOtherType
Definition ObjectPtr.h:1085
static void ReinterpretRange(IterBeginType Iter, IterEndType IterEnd, OperatorType Operator=TContainerElementTypeCompatibility_DefaultOperatorFunc)
Definition ObjectPtr.h:1132
static void ReinterpretRangeContiguous(IterBeginType Iter, IterEndType IterEnd, SizeType Size, OperatorType Operator=TContainerElementTypeCompatibility_DefaultOperatorFunc)
Definition ObjectPtr.h:1146
T *const CopyFromOtherType
Definition ObjectPtr.h:1128
T *const ReinterpretType
Definition ObjectPtr.h:1127
Definition ContainerElementTypeCompatibility.h:15
static constexpr void CopyingFromOtherType()
Definition ContainerElementTypeCompatibility.h:29
TCopyQualifiersFromTo_T< From, To > Type
Definition CopyQualifiersAndRefsFromTo.h:13
TDereferenceWrapper(const PREDICATE_CLASS &InPredicate)
Definition ObjectPtr.h:1186
const PREDICATE_CLASS & Predicate
Definition ObjectPtr.h:1184
FORCEINLINE bool operator()(const TObjectPtr< T > &A, const TObjectPtr< T > &B) const
Definition ObjectPtr.h:1190
Definition Sorting.h:16
const PREDICATE_CLASS & Predicate
Definition Sorting.h:17
Definition UnrealTypeTraits.h:410
Definition ObjectPtr.h:1305
@ Value
Definition ObjectPtr.h:1306
Definition ObjectPtr.h:1323
@ Value
Definition ObjectPtr.h:1324
Definition UnrealTypeTraits.h:172
Definition ObjectPtr.h:488
TObjectPtr(TObjectPtr< T > &&Other)
Definition ObjectPtr.h:508
FORCEINLINE bool IsResolved() const
Definition ObjectPtr.h:726
FORCEINLINE FString GetPathName() const
Definition ObjectPtr.h:738
FORCEINLINE bool UEOpEquals(const U &Other) const
Definition ObjectPtr.h:653
constexpr FORCEINLINE TObjectPtr(ENoInit)
Definition ObjectPtr.h:521
FORCEINLINE UClass * GetClass() const
Definition ObjectPtr.h:665
FORCEINLINE TObjectPtr< UPackage > GetPackage() const
Definition ObjectPtr.h:672
FORCEINLINE TObjectPtr< T > & operator=(U &&Object)
Definition ObjectPtr.h:608
FORCEINLINE TObjectPtr< T > & operator=(const TObjectPtr< U > &Other)
Definition ObjectPtr.h:597
FORCEINLINE TObjectPtr< T > & operator=(TPrivateObjectPtr< T > &&PrivatePtr)
Definition ObjectPtr.h:614
FORCEINLINE T * operator->() const
Definition ObjectPtr.h:703
FORCEINLINE bool UEOpEquals(const TObjectPtr< U > &Other) const
Definition ObjectPtr.h:625
TObjectPtr< T > & operator=(TObjectPtr< T > &&Other)
Definition ObjectPtr.h:572
FORCEINLINE FString GetName() const
Definition ObjectPtr.h:746
FORCEINLINE TObjectPtr(TPrivateObjectPtr< T > &&PrivatePtr)
Definition ObjectPtr.h:566
FORCEINLINE constexpr TObjectPtr(const TObjectPtr< U > &Other)
Definition ObjectPtr.h:545
FORCEINLINE consteval TObjectPtr(EConstEval, T *Object)
Definition ObjectPtr.h:536
TObjectPtr< T > & operator=(const TObjectPtr< T > &Other)
Definition ObjectPtr.h:577
FORCEINLINE FObjectHandle GetHandle() const
Definition ObjectPtr.h:754
T ElementType
Definition ObjectPtr.h:500
FORCEINLINE bool IsIn(TObjectPtr< U > SomeOuter) const
Definition ObjectPtr.h:684
FORCEINLINE T * Get() const
Definition ObjectPtr.h:664
FORCEINLINE bool IsA(const UClass *SomeBase) const
Definition ObjectPtr.h:758
FORCEINLINE constexpr TObjectPtr(FObjectPtr ObjPtr)
Definition ObjectPtr.h:531
TObjectPtr(const TObjectPtr< T > &Other)
Definition ObjectPtr.h:512
FORCEINLINE bool IsIn(FObjectPtr SomeOuter) const
Definition ObjectPtr.h:678
FORCEINLINE bool operator!() const
Definition ObjectPtr.h:718
FORCEINLINE uint32 GetPtrTypeHash() const
Definition ObjectPtr.h:768
FORCEINLINE bool IsA() const
Definition ObjectPtr.h:763
TObjectPtr< T > & GetAccessTrackedObjectPtr()
Definition ObjectPtr.h:778
FORCEINLINE TObjectPtr< T > & operator=(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:587
T * DebugPtr
Definition ObjectPtr.h:821
FObjectPtr ObjectPtr
Definition ObjectPtr.h:818
FORCEINLINE FString GetFullName(EObjectFullNameFlags Flags=EObjectFullNameFlags::None) const
Definition ObjectPtr.h:750
FORCEINLINE FString GetPath() const
Definition ObjectPtr.h:734
FORCEINLINE TObjectPtr< UObject > GetOuter() const
Definition ObjectPtr.h:666
constexpr TObjectPtr()
Definition ObjectPtr.h:502
const TObjectPtr< T > & GetAccessTrackedObjectPtr() const
Definition ObjectPtr.h:783
FORCEINLINE FName GetFName() const
Definition ObjectPtr.h:742
FORCEINLINE void SerializePtrStructured(FStructuredArchiveSlot Slot)
Definition ObjectPtr.h:773
FORCEINLINE TObjectPtr(T &Object)
Definition ObjectPtr.h:561
constexpr FORCEINLINE TObjectPtr(const U &Object)
Definition ObjectPtr.h:555
FORCEINLINE bool IsRemote() const
Definition ObjectPtr.h:730
FORCEINLINE constexpr TObjectPtr(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:526
FORCEINLINE T & operator*() const
Definition ObjectPtr.h:707
FORCEINLINE bool UEOpEquals(TYPE_OF_NULLPTR) const
Definition ObjectPtr.h:643
friend struct TObjectPtr
Definition ObjectPtr.h:797
T Type
Definition ObjectPtr.h:1350
T Type
Definition ObjectPtr.h:1344
Definition ObjectPtr.h:1339
Definition ObjectPtr.h:970
TPrivateObjectPtr(const TPrivateObjectPtr< T > &Other)=default
T Type
Definition ObjectPtr.h:835
Definition ObjectPtr.h:829
T Type
Definition ObjectPtr.h:830
Definition WeakObjectPtrTemplates.h:25
static void Close(ViewType &View)
Definition ObjectPtr.h:1508
static void Close(ViewType &View)
Definition ObjectPtr.h:1549
static void Close(ViewType &View)
Definition ObjectPtr.h:1494
static void Close(ViewType &View)
Definition ObjectPtr.h:1529
Definition ObjectPtr.h:1487
static FORCEINLINE void PerformDecayActions(const TArray< T > &Value)
Definition ObjectPtr.h:1415
static FORCEINLINE void PerformDecayActions(const TMap< K, V > &Value)
Definition ObjectPtr.h:1400
static FORCEINLINE void PerformDecayActions(const TNonNullPtr< TObjectPtr< T > > &Value)
Definition ObjectPtr.h:1429
static FORCEINLINE void PerformDecayActions(const TObjectPtr< T > &Value)
Definition ObjectPtr.h:1372
static FORCEINLINE void PerformDecayActions(const TSet< T > &Value)
Definition ObjectPtr.h:1386
TSet< typename TObjectPtrDecayTypeOf< T >::Type > Type
Definition ObjectPtr.h:1384
Definition ObjectPtr.h:1362
static FORCEINLINE void PerformDecayActions(const T &)
Definition ObjectPtr.h:1364
T Type
Definition ObjectPtr.h:1363
TSet< typename TObjectPtrWrapTypeOf< T >::Type > Type
Definition ObjectPtr.h:1464
Definition ObjectPtr.h:1439
T Type
Definition ObjectPtr.h:1440