UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SharedPointer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
9#include "HAL/UnrealMemory.h"
10#include "Containers/Array.h"
11#include "Containers/Map.h"
12#include "CoreGlobals.h"
13#include "Misc/UEOps.h"
14
15
117// SharedPointerInternals.h contains the implementation of reference counting structures we need
118#include "Templates/SharedPointerInternals.h" // IWYU pragma: export
119
120
126template< class CastToType, class CastFromType, ESPMode Mode >
131
132
133namespace UE::Core::Private
134{
135 // Needed to work around an Android compiler bug - we need to construct a TSharedRef
136 // from MakeShared without making MakeShared a friend in order to access the private constructor.
137 template <typename ObjectType, ESPMode Mode>
142}
143
144
150// NOTE: TSharedRef is an Unreal extension to standard smart pointer feature set
151template< class ObjectType, ESPMode InMode >
153{
154public:
155 static_assert(!std::is_void_v<ObjectType>, "TSharedRef<void> is not supported - use TSharedPtr instead");
156
157 using ElementType = ObjectType;
158 static constexpr ESPMode Mode = InMode;
159
160 // NOTE: TSharedRef has no default constructor as it does not support empty references. You must
161 // initialize your TSharedRef to a valid object at construction time.
162
168 template <
169 typename OtherType
170 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
171 >
172 inline explicit TSharedRef( OtherType* InObject )
173 : Object( InObject )
174 , SharedReferenceCount( SharedPointerInternals::NewDefaultReferenceController< Mode >( InObject ) )
175 {
176 Init(InObject);
177 }
178
185 template <
186 typename OtherType,
187 typename DeleterType
188 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
189 >
190 inline TSharedRef( OtherType* InObject, DeleterType&& InDeleter )
191 : Object( InObject )
192 , SharedReferenceCount( SharedPointerInternals::NewCustomReferenceController< Mode >( InObject, Forward< DeleterType >( InDeleter ) ) )
193 {
194 Init(InObject);
195 }
196
203 : Object(new ObjectType())
204 , SharedReferenceCount(SharedPointerInternals::NewDefaultReferenceController<Mode>(Object))
205 {
207 Init(Object);
208 }
209
216 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
217 template <
218 typename OtherType
219 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
220 >
222 : Object( InRawPtrProxy.Object )
223 , SharedReferenceCount( SharedPointerInternals::NewDefaultReferenceController< Mode >( InRawPtrProxy.Object ) )
224 {
225 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
226 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
227 check( InRawPtrProxy.Object != nullptr );
228
229 // If the object happens to be derived from TSharedFromThis, the following method
230 // will prime the object with a weak pointer to itself.
232 }
233
240 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
241 template <
242 typename OtherType,
243 typename DeleterType
244 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
245 >
247 : Object( InRawPtrProxy.Object )
248 , SharedReferenceCount( SharedPointerInternals::NewCustomReferenceController< Mode >( InRawPtrProxy.Object, InRawPtrProxy.Deleter ) )
249 {
250 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
251 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
252 check( InRawPtrProxy.Object != nullptr );
253
254 // If the object happens to be derived from TSharedFromThis, the following method
255 // will prime the object with a weak pointer to itself.
257 }
258
265 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
266 template <
267 typename OtherType,
268 typename DeleterType
269 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
270 >
272 : Object( InRawPtrProxy.Object )
273 , SharedReferenceCount( SharedPointerInternals::NewCustomReferenceController< Mode >( InRawPtrProxy.Object, MoveTemp( InRawPtrProxy.Deleter ) ) )
274 {
275 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
276 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
277 check( InRawPtrProxy.Object != nullptr );
278
279 // If the object happens to be derived from TSharedFromThis, the following method
280 // will prime the object with a weak pointer to itself.
282 }
283
290 template <
291 typename OtherType
292 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
293 >
295 : Object( InSharedRef.Object )
296 , SharedReferenceCount( InSharedRef.SharedReferenceCount )
297 {
298 }
299
308 template <typename OtherType>
310 : Object( static_cast< ObjectType* >( InSharedRef.Object ) )
311 , SharedReferenceCount( InSharedRef.SharedReferenceCount )
312 {
313 }
314
323 template <typename OtherType>
325 : Object( const_cast< ObjectType* >( InSharedRef.Object ) )
326 , SharedReferenceCount( InSharedRef.SharedReferenceCount )
327 {
328 }
329
337 template <typename OtherType>
338 inline TSharedRef( TSharedRef< OtherType, Mode > const& OtherSharedRef, ObjectType* InObject )
339 : Object( InObject )
340 , SharedReferenceCount( OtherSharedRef.SharedReferenceCount )
341 {
342 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
343 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
344 check( InObject != nullptr );
345 }
346
348 : Object( InSharedRef.Object )
349 , SharedReferenceCount( InSharedRef.SharedReferenceCount )
350 { }
351
353 : Object( InSharedRef.Object )
354 , SharedReferenceCount( InSharedRef.SharedReferenceCount )
355 {
356 // We're intentionally not moving here, because we don't want to leave InSharedRef in a
357 // null state, because that breaks the class invariant. But we provide a move constructor
358 // anyway in case the compiler complains that we have a move assign but no move construct.
359 }
360
369 {
370 TSharedRef Temp = InSharedRef;
371 ::Swap(Temp, *this);
372 return *this;
373 }
374
376 {
377 ::Swap(*this, InSharedRef);
378 return *this;
379 }
380
388 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
389 template <
390 typename OtherType
391 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
392 >
394 {
395 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
396 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
397 check( InRawPtrProxy.Object != nullptr );
398
400 return *this;
401 }
402
410 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
411 template <
412 typename OtherType,
413 typename DeleterType
414 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
415 >
417 {
418 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
419 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
420 check( InRawPtrProxy.Object != nullptr );
421
423 return *this;
424 }
425
433 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
434 template <
435 typename OtherType,
436 typename DeleterType
437 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
438 >
440 {
441 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
442 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
443 check( InRawPtrProxy.Object != nullptr );
444
446 return *this;
447 }
448
458
468
474 [[nodiscard]] inline ObjectType& Get() const
475 {
476 // Should never be nullptr as TSharedRef is never nullable
477 checkSlow( IsValid() );
478 return *Object;
479 }
480
486 [[nodiscard]] inline ObjectType& operator*() const
487 {
488 // Should never be nullptr as TSharedRef is never nullable
489 checkSlow( IsValid() );
490 return *Object;
491 }
492
498 [[nodiscard]] inline ObjectType* operator->() const
499 {
500 // Should never be nullptr as TSharedRef is never nullable
501 checkSlow( IsValid() );
502 return Object;
503 }
504
512 {
513 return SharedReferenceCount.GetSharedReferenceCount();
514 }
515
528 {
529 return SharedReferenceCount.IsUnique();
530 }
531
533 // Start - intrusive TOptional<TSharedRef> state //
535 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
537
539 : Object(nullptr)
540 {
541 }
543 {
544 return !IsValid();
545 }
547 // End - intrusive TOptional<TSharedRef> state //
549
550 template <typename OtherType>
552 {
553 return this->Object == &Rhs.Get();
554 }
555
556 template <typename OtherType>
558 {
559 // This comparison against null is maintained as existing behavior, but isn't consistent with TWeakPtr comparison.
560 OtherType* RhsPtr = Rhs.Get();
561 return RhsPtr && RhsPtr == this->Object;
562 }
563
564 template <typename OtherType>
566 {
567 return this->Object == Rhs.Pin().Get();
568 }
569
570 template <typename OtherType>
572 {
573 return this->Object < &Rhs.Get();
574 }
575
576private:
577 template<class OtherType>
578 void Init(OtherType* InObject)
579 {
580 // If the following assert goes off, it means a TSharedRef was initialized from a nullptr object pointer.
581 // Shared references must never be nullptr, so either pass a valid object or consider using TSharedPtr instead.
582 check(InObject != nullptr);
583
584 // If the object happens to be derived from TSharedFromThis, the following method
585 // will prime the object with a weak pointer to itself.
587 }
588
595 template <
596 typename OtherType
597 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
598 >
600 : Object( InSharedPtr.Object )
601 , SharedReferenceCount( InSharedPtr.SharedReferenceCount )
602 {
603 // If this assert goes off, it means a shared reference was created from a shared pointer that was nullptr.
604 // Shared references are never allowed to be null. Consider using TSharedPtr instead.
605 check( IsValid() );
606 }
607
608 template <
609 typename OtherType
610 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
611 >
613 : Object( InSharedPtr.Object )
614 , SharedReferenceCount( MoveTemp(InSharedPtr.SharedReferenceCount) )
615 {
616 InSharedPtr.Object = nullptr;
617
618 // If this assert goes off, it means a shared reference was created from a shared pointer that was nullptr.
619 // Shared references are never allowed to be null. Consider using TSharedPtr instead.
620 check( IsValid() );
621 }
622
629 [[nodiscard]] UE_FORCEINLINE_HINT bool IsValid() const
630 {
631 return Object != nullptr;
632 }
633
634 // We declare ourselves as a friend (templated using OtherType) so we can access members as needed
635 template< class OtherType, ESPMode OtherMode > friend class TSharedRef;
636
637 // Declare other smart pointer types as friends as needed
638 template< class OtherType, ESPMode OtherMode > friend class TSharedPtr;
639 template< class OtherType, ESPMode OtherMode > friend class TWeakPtr;
640
641private:
642
644 ObjectType* Object;
645
649
650 // VC emits an erroneous warning here - there is no inline specifier!
651 #ifdef _MSC_VER
652 #pragma warning(push)
653 #pragma warning(disable : 4396) // warning: the inline specifier cannot be used when a friend declaration refers to a specialization of a function template
654 #endif
655
656 friend TSharedRef UE::Core::Private::MakeSharedRef<ObjectType, Mode>(ObjectType* InObject, SharedPointerInternals::TReferenceControllerBase<Mode>* InSharedReferenceCount);
657
658 #ifdef _MSC_VER
659 #pragma warning(pop)
660 #endif
661
663 : Object(InObject)
664 , SharedReferenceCount(InSharedReferenceCount)
665 {
666 Init(InObject);
667 }
668};
669
673template <typename T> constexpr bool TIsTSharedRef_V = false;
674template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedRef_V< TSharedRef<ObjectType, InMode>> = true;
675template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedRef_V<const TSharedRef<ObjectType, InMode>> = true;
676template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedRef_V< volatile TSharedRef<ObjectType, InMode>> = true;
677template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedRef_V<const volatile TSharedRef<ObjectType, InMode>> = true;
678
679template <class ObjectType, ESPMode Mode>
680struct TCallTraits<TSharedRef<ObjectType, Mode>> : public TCallTraitsBase<TSharedRef<ObjectType, Mode>>
681{
683};
684
685
690template< class ObjectType, ESPMode InMode >
692{
693public:
694 using ElementType = ObjectType;
695 static constexpr ESPMode Mode = InMode;
696
700 // NOTE: FNullTag parameter is an Unreal extension to standard shared_ptr behavior
702 : Object( nullptr )
703 , SharedReferenceCount()
704 {
705 }
706
713 template <
714 typename OtherType
715 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
716 >
717 inline explicit TSharedPtr( OtherType* InObject )
718 : Object( InObject )
719 , SharedReferenceCount( SharedPointerInternals::NewDefaultReferenceController< Mode >( InObject ) )
720 {
721 // If the object happens to be derived from TSharedFromThis, the following method
722 // will prime the object with a weak pointer to itself.
724 }
725
733 template <
734 typename OtherType,
735 typename DeleterType
736 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
737 >
738 inline TSharedPtr( OtherType* InObject, DeleterType&& InDeleter )
739 : Object( InObject )
740 , SharedReferenceCount( SharedPointerInternals::NewCustomReferenceController< Mode >( InObject, Forward< DeleterType >( InDeleter ) ) )
741 {
742 // If the object happens to be derived from TSharedFromThis, the following method
743 // will prime the object with a weak pointer to itself.
745 }
746
752 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
753 template <
754 typename OtherType
755 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
756 >
758 : Object( InRawPtrProxy.Object )
759 , SharedReferenceCount( SharedPointerInternals::NewDefaultReferenceController< Mode >( InRawPtrProxy.Object ) )
760 {
761 // If the object happens to be derived from TSharedFromThis, the following method
762 // will prime the object with a weak pointer to itself.
764 }
765
771 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
772 template <
773 typename OtherType,
774 typename DeleterType
775 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
776 >
778 : Object( InRawPtrProxy.Object )
779 , SharedReferenceCount( SharedPointerInternals::NewCustomReferenceController< Mode >( InRawPtrProxy.Object, InRawPtrProxy.Deleter ) )
780 {
781 // If the object happens to be derived from TSharedFromThis, the following method
782 // will prime the object with a weak pointer to itself.
784 }
785
791 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
792 template <
793 typename OtherType,
794 typename DeleterType
795 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
796 >
798 : Object( InRawPtrProxy.Object )
799 , SharedReferenceCount( SharedPointerInternals::NewCustomReferenceController< Mode >( InRawPtrProxy.Object, MoveTemp( InRawPtrProxy.Deleter ) ) )
800 {
801 // If the object happens to be derived from TSharedFromThis, the following method
802 // will prime the object with a weak pointer to itself.
804 }
805
812 template <
813 typename OtherType
814 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
815 >
817 : Object( InSharedPtr.Object )
818 , SharedReferenceCount( InSharedPtr.SharedReferenceCount )
819 {
820 }
821
823 : Object( InSharedPtr.Object )
824 , SharedReferenceCount( InSharedPtr.SharedReferenceCount )
825 {
826 }
827
829 : Object( InSharedPtr.Object )
830 , SharedReferenceCount( MoveTemp(InSharedPtr.SharedReferenceCount) )
831 {
832 InSharedPtr.Object = nullptr;
833 }
834
841 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
842 template <
843 typename OtherType
844 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
845 >
847 : Object( InSharedRef.Object )
848 , SharedReferenceCount( InSharedRef.SharedReferenceCount )
849 {
850 // There is no rvalue overload of this constructor, because 'stealing' the pointer from a
851 // TSharedRef would leave it as null, which would invalidate its invariant.
852 }
853
862 template <typename OtherType>
864 : Object( static_cast< ObjectType* >( InSharedPtr.Object ) )
865 , SharedReferenceCount( InSharedPtr.SharedReferenceCount )
866 {
867 }
868
877 template <typename OtherType>
879 : Object( const_cast< ObjectType* >( InSharedPtr.Object ) )
880 , SharedReferenceCount( InSharedPtr.SharedReferenceCount )
881 {
882 }
883
891 template <typename OtherType>
892 inline TSharedPtr( TSharedPtr< OtherType, Mode > const& OtherSharedPtr, ObjectType* InObject )
893 : Object( InObject )
894 , SharedReferenceCount( OtherSharedPtr.SharedReferenceCount )
895 {
896 }
897
905 template <typename OtherType>
907 : Object( InObject )
908 , SharedReferenceCount( MoveTemp(OtherSharedPtr.SharedReferenceCount) )
909 {
910 OtherSharedPtr.Object = nullptr;
911 }
912
920 template <typename OtherType>
921 inline TSharedPtr( TSharedRef< OtherType, Mode > const& OtherSharedRef, ObjectType* InObject )
922 : Object( InObject )
923 , SharedReferenceCount( OtherSharedRef.SharedReferenceCount )
924 {
925 }
926
931 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
933 {
934 Reset();
935 return *this;
936 }
937
946 {
947 TSharedPtr Temp = InSharedPtr;
948 ::Swap(Temp, *this);
949 return *this;
950 }
951
952 // Disable false positive buffer overrun warning during pgo linking step
955 {
956 if (this != &InSharedPtr)
957 {
958 Object = InSharedPtr.Object;
959 InSharedPtr.Object = nullptr;
960 SharedReferenceCount = MoveTemp(InSharedPtr.SharedReferenceCount);
961 }
962 return *this;
963 }
965
973 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
974 template <
975 typename OtherType
976 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
977 >
983
991 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
992 template <
993 typename OtherType,
994 typename DeleterType
995 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
996 >
1002
1010 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
1011 template <
1012 typename OtherType,
1013 typename DeleterType
1014 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1015 >
1021
1027 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
1029 {
1030 // If this assert goes off, it means a shared reference was created from a shared pointer that was nullptr.
1031 // Shared references are never allowed to be null. Consider using TSharedPtr instead.
1032 check( IsValid() );
1033 return TSharedRef< ObjectType, Mode >( *this );
1034 }
1035
1041 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
1043 {
1044 // If this assert goes off, it means a shared reference was created from a shared pointer that was nullptr.
1045 // Shared references are never allowed to be null. Consider using TSharedPtr instead.
1046 check( IsValid() );
1047 return TSharedRef< ObjectType, Mode >( MoveTemp( *this ) );
1048 }
1049
1059
1065 [[nodiscard]] UE_FORCEINLINE_HINT ObjectType* Get() const
1066 {
1067 return Object;
1068 }
1069
1075 [[nodiscard]] UE_FORCEINLINE_HINT explicit operator bool() const
1076 {
1077 return Object != nullptr;
1078 }
1079
1086 {
1087 return Object != nullptr;
1088 }
1089
1095 template <
1096 typename DummyObjectType = ObjectType
1097 UE_REQUIRES(UE_REQUIRES_EXPR(*(DummyObjectType*)nullptr)) // this construct means that operator* is only considered for overload resolution if T is dereferenceable
1098 >
1100 {
1101 check( IsValid() );
1102 return *Object;
1103 }
1104
1110 [[nodiscard]] inline ObjectType* operator->() const
1111 {
1112 check( IsValid() );
1113 return Object;
1114 }
1115
1121 {
1123 }
1124
1132 {
1133 return SharedReferenceCount.GetSharedReferenceCount();
1134 }
1135
1144 {
1145 return SharedReferenceCount.IsUnique();
1146 }
1147
1149 // Start - intrusive TOptional<TSharedPtr> state //
1151 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
1153
1155 : Object((ObjectType*)-1)
1156 {
1157 }
1159 {
1160 return Object == (ObjectType*)-1;
1161 }
1163 // End - intrusive TOptional<TSharedPtr> state //
1165
1166 template <typename OtherType>
1167 [[nodiscard]] inline bool UEOpEquals(const TSharedPtr<OtherType, Mode>& Rhs) const
1168 {
1169 return this->Object == Rhs.Get();
1170 }
1171
1172 template <typename OtherType>
1174 {
1175 return this->Object == Rhs.Pin().Get();
1176 }
1177
1179 {
1180 return !this->Object;
1181 }
1182
1183 template <typename OtherType>
1184 [[nodiscard]] inline bool UEOpLessThan(const TSharedPtr<OtherType, Mode>& Rhs) const
1185 {
1186 return this->Object < Rhs.Get();
1187 }
1188
1189private:
1199 template <
1200 typename OtherType
1201 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1202 >
1203 inline explicit TSharedPtr( TWeakPtr< OtherType, Mode > const& InWeakPtr )
1204 : Object( nullptr )
1205 , SharedReferenceCount( InWeakPtr.WeakReferenceCount )
1206 {
1207 // Check that the shared reference was created from the weak reference successfully. We'll only
1208 // cache a pointer to the object if we have a valid shared reference.
1209 if( SharedReferenceCount.IsValid() )
1210 {
1211 Object = InWeakPtr.Object;
1212 }
1213 }
1214
1224 template <
1225 typename OtherType
1226 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1227 >
1229 : Object(nullptr)
1230 , SharedReferenceCount( MoveTemp( InWeakPtr.WeakReferenceCount ) )
1231 {
1232 // Check that the shared reference was created from the weak reference successfully. We'll only
1233 // cache a pointer to the object if we have a valid shared reference.
1234 if (SharedReferenceCount.IsValid())
1235 {
1236 Object = InWeakPtr.Object;
1237 InWeakPtr.Object = nullptr;
1238 }
1239 }
1240
1241 // We declare ourselves as a friend (templated using OtherType) so we can access members as needed
1242 template< class OtherType, ESPMode OtherMode > friend class TSharedPtr;
1243
1244 // Declare other smart pointer types as friends as needed
1245 template< class OtherType, ESPMode OtherMode > friend class TSharedRef;
1246 template< class OtherType, ESPMode OtherMode > friend class TWeakPtr;
1247 template< class OtherType, ESPMode OtherMode > friend class TSharedFromThis;
1248
1249private:
1250
1252 ObjectType* Object;
1253
1257};
1258
1262template <typename T> constexpr bool TIsTSharedPtr_V = false;
1263template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedPtr_V< TSharedPtr<ObjectType, InMode>> = true;
1264template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedPtr_V<const TSharedPtr<ObjectType, InMode>> = true;
1265template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedPtr_V< volatile TSharedPtr<ObjectType, InMode>> = true;
1266template <class ObjectType, ESPMode InMode> constexpr bool TIsTSharedPtr_V<const volatile TSharedPtr<ObjectType, InMode>> = true;
1267
1268namespace Freeze
1269{
1270 template<class ObjectType, ESPMode Mode>
1272 {
1273 // we never want to freeze pointers, so write an empty one
1275 }
1276}
1277
1279
1280template<class ObjectType, ESPMode Mode> struct TIsZeroConstructType<TSharedPtr<ObjectType, Mode>> { enum { Value = true }; };
1281
1282template <class ObjectType, ESPMode Mode>
1283struct TCallTraits<TSharedPtr<ObjectType, Mode>> : public TCallTraitsBase<TSharedPtr<ObjectType, Mode>>
1284{
1286};
1287
1288
1293template< class ObjectType, ESPMode InMode >
1295{
1296public:
1297 using ElementType = ObjectType;
1298 static constexpr ESPMode Mode = InMode;
1299
1301 // NOTE: FNullTag parameter is an Unreal extension to standard shared_ptr behavior
1303 : Object( nullptr )
1304 , WeakReferenceCount()
1305 {
1306 }
1307
1313 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
1314 template <
1315 typename OtherType
1316 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1317 >
1319 : Object( InSharedRef.Object )
1320 , WeakReferenceCount( InSharedRef.SharedReferenceCount )
1321 {
1322 }
1323
1329 template <
1330 typename OtherType
1331 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1332 >
1334 : Object( InSharedPtr.Object )
1335 , WeakReferenceCount( InSharedPtr.SharedReferenceCount )
1336 {
1337 }
1338
1347 template <typename OtherType>
1349 : Object(static_cast<ObjectType*>(InWeakPtr.Object))
1350 , WeakReferenceCount(InWeakPtr.WeakReferenceCount)
1351 {
1352 }
1353
1362 template <typename OtherType>
1364 : Object(const_cast<ObjectType*>(InWeakPtr.Object))
1365 , WeakReferenceCount(InWeakPtr.WeakReferenceCount)
1366 {
1367 }
1368
1375 template <
1376 typename OtherType
1377 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1378 >
1380 : Object( InWeakPtr.Object )
1381 , WeakReferenceCount( InWeakPtr.WeakReferenceCount )
1382 {
1383 }
1384
1385 template <
1386 typename OtherType
1387 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1388 >
1390 : Object( InWeakPtr.Object )
1391 , WeakReferenceCount( MoveTemp(InWeakPtr.WeakReferenceCount) )
1392 {
1393 InWeakPtr.Object = nullptr;
1394 }
1395
1396 inline TWeakPtr( TWeakPtr const& InWeakPtr )
1397 : Object( InWeakPtr.Object )
1398 , WeakReferenceCount( InWeakPtr.WeakReferenceCount )
1399 {
1400 }
1401
1403 : Object( InWeakPtr.Object )
1404 , WeakReferenceCount( MoveTemp(InWeakPtr.WeakReferenceCount) )
1405 {
1406 InWeakPtr.Object = nullptr;
1407 }
1408
1412 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
1414 {
1415 Reset();
1416 return *this;
1417 }
1418
1425 {
1426 TWeakPtr Temp = InWeakPtr;
1427 ::Swap(Temp, *this);
1428 return *this;
1429 }
1430
1432 {
1433 if (this != &InWeakPtr)
1434 {
1435 Object = InWeakPtr.Object;
1436 InWeakPtr.Object = nullptr;
1437 WeakReferenceCount = MoveTemp(InWeakPtr.WeakReferenceCount);
1438 }
1439 return *this;
1440 }
1441
1448 template <
1449 typename OtherType
1450 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1451 >
1453 {
1454 Object = InWeakPtr.Pin().Get();
1455 WeakReferenceCount = InWeakPtr.WeakReferenceCount;
1456 return *this;
1457 }
1458
1459 template <
1460 typename OtherType
1461 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1462 >
1464 {
1465 Object = InWeakPtr.Object;
1466 InWeakPtr.Object = nullptr;
1467 WeakReferenceCount = MoveTemp(InWeakPtr.WeakReferenceCount);
1468 return *this;
1469 }
1470
1476 // NOTE: The following is an Unreal extension to standard shared_ptr behavior
1477 template <
1478 typename OtherType
1479 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1480 >
1482 {
1483 Object = InSharedRef.Object;
1484 WeakReferenceCount = InSharedRef.SharedReferenceCount;
1485 return *this;
1486 }
1487
1493 template <
1494 typename OtherType
1495 UE_REQUIRES(std::is_convertible_v<OtherType*, ObjectType*>)
1496 >
1498 {
1499 Object = InSharedPtr.Object;
1500 WeakReferenceCount = InSharedPtr.SharedReferenceCount;
1501 return *this;
1502 }
1503
1516
1529
1536 {
1537 return Object != nullptr && WeakReferenceCount.IsValid();
1538 }
1539
1545 {
1547 }
1548
1553 {
1554 return Pin().Get() == InOtherPtr;
1555 }
1556
1558 {
1559 return ::PointerHash( Object );
1560 }
1561
1563 // Start - intrusive TOptional<TWeakPtr> state //
1565 constexpr static bool bHasIntrusiveUnsetOptionalState = true;
1567
1569 : Object((ObjectType*)-1)
1570 {
1571 }
1573 {
1574 return Object == (ObjectType*)-1;
1575 }
1577 // End - intrusive TOptional<TWeakPtr> state //
1579
1580 template <typename OtherType>
1581 [[nodiscard]] inline bool UEOpEquals(const TWeakPtr<OtherType, Mode>& Rhs) const
1582 {
1583 return this->Pin().Get() == Rhs.Pin().Get();
1584 }
1585
1587 {
1588 return !this->IsValid();
1589 }
1590
1591 template <typename OtherType>
1592 [[nodiscard]] inline bool UEOpLessThan(const TWeakPtr<OtherType, Mode>& Rhs) const
1593 {
1594 return this->Pin().Get() < Rhs.Pin().Get();
1595 }
1596
1597private:
1598 // We declare ourselves as a friend (templated using OtherType) so we can access members as needed
1599 template< class OtherType, ESPMode OtherMode > friend class TWeakPtr;
1600
1601 // Declare ourselves as a friend of TSharedPtr so we can access members as needed
1602 template< class OtherType, ESPMode OtherMode > friend class TSharedPtr;
1603
1604private:
1607 ObjectType* Object;
1608
1612};
1613
1617template <typename T> constexpr bool TIsTWeakPtr_V = false;
1618template <class ObjectType, ESPMode InMode> constexpr bool TIsTWeakPtr_V< TWeakPtr<ObjectType, InMode>> = true;
1619template <class ObjectType, ESPMode InMode> constexpr bool TIsTWeakPtr_V<const TWeakPtr<ObjectType, InMode>> = true;
1620template <class ObjectType, ESPMode InMode> constexpr bool TIsTWeakPtr_V< volatile TWeakPtr<ObjectType, InMode>> = true;
1621template <class ObjectType, ESPMode InMode> constexpr bool TIsTWeakPtr_V<const volatile TWeakPtr<ObjectType, InMode>> = true;
1622
1623
1624template<class T, ESPMode Mode> struct TIsWeakPointerType<TWeakPtr<T, Mode> > { enum { Value = true }; };
1625template<class T, ESPMode Mode> struct TIsZeroConstructType<TWeakPtr<T, Mode> > { enum { Value = true }; };
1626
1627template <class ObjectType, ESPMode Mode>
1628struct TCallTraits<TWeakPtr<ObjectType, Mode>> : public TCallTraitsBase<TWeakPtr<ObjectType, Mode>>
1629{
1631};
1632
1633
1638template< class ObjectType, ESPMode Mode >
1639class TSharedFromThis : private UE::Core::Private::FSharedFromThisBase
1640{
1641public:
1642
1651 {
1653
1654 //
1655 // If the following assert goes off, it means one of the following:
1656 //
1657 // - You tried to request a shared reference before the object was ever assigned to one. (e.g. constructor)
1658 // - You tried to request a shared reference while the object is being destroyed (destructor chain)
1659 //
1660 // To fix this, make sure you create at least one shared reference to your object instance before requested,
1661 // and also avoid calling this function from your object's destructor.
1662 //
1663 check( SharedThis.Get() == this );
1664
1665 // Now that we've verified the shared pointer is valid, we'll convert it to a shared reference
1666 // and return it!
1667 return MoveTemp( SharedThis ).ToSharedRef();
1668 }
1669
1678 {
1680
1681 //
1682 // If the following assert goes off, it means one of the following:
1683 //
1684 // - You tried to request a shared reference before the object was ever assigned to one. (e.g. constructor)
1685 // - You tried to request a shared reference while the object is being destroyed (destructor chain)
1686 //
1687 // To fix this, make sure you create at least one shared reference to your object instance before requested,
1688 // and also avoid calling this function from your object's destructor.
1689 //
1690 check( SharedThis.Get() == this );
1691
1692 // Now that we've verified the shared pointer is valid, we'll convert it to a shared reference
1693 // and return it!
1694 return MoveTemp( SharedThis ).ToSharedRef();
1695 }
1696
1705 template< typename SubobjectType >
1710
1719 {
1720 TWeakPtr< ObjectType, Mode > Result = WeakThis;
1721
1722 //
1723 // If the following assert goes off, it means one of the following:
1724 //
1725 // - You tried to request a weak pointer before the object was ever assigned to a shared pointer. (e.g. constructor)
1726 // - You tried to request a weak pointer while the object is being destroyed (destructor chain)
1727 //
1728 // To fix this, make sure you create at least one shared reference to your object instance before requested,
1729 // and also avoid calling this function from your object's destructor.
1730 //
1731 check( Result.Pin().Get() == this );
1732
1733 // Now that we've verified the pointer is valid, we'll return it!
1734 return Result;
1735 }
1737 {
1738 TWeakPtr< ObjectType const, Mode > Result = WeakThis;
1739
1740 //
1741 // If the following assert goes off, it means one of the following:
1742 //
1743 // - You tried to request a weak pointer before the object was ever assigned to a shared pointer. (e.g. constructor)
1744 // - You tried to request a weak pointer while the object is being destroyed (destructor chain)
1745 //
1746 // To fix this, make sure you create at least one shared reference to your object instance before requested,
1747 // and also avoid calling this function from your object's destructor.
1748 //
1749 check( Result.Pin().Get() == this );
1750
1751 // Now that we've verified the pointer is valid, we'll return it!
1752 return Result;
1753 }
1754
1763 template <typename SubobjectType>
1768
1769protected:
1770
1779 template< class OtherType >
1784
1793 template< class OtherType >
1798
1799public: // @todo: Ideally this would be private, but template sharing problems prevent it
1800
1806 template< class SharedPtrType, ESPMode SharedPtrMode, class OtherType >
1808 {
1809 static_assert(SharedPtrMode == Mode, "You cannot use a TSharedPtr of one mode with a type which inherits TSharedFromThis of another mode.");
1810
1811 if( !WeakThis.IsValid() )
1812 {
1813 WeakThis = TSharedPtr< ObjectType, Mode >( *InSharedPtr, InObject );
1814 }
1815 }
1816
1822 template< class SharedRefType, ESPMode SharedPtrMode, class OtherType >
1824 {
1825 static_assert(SharedPtrMode == Mode, "You cannot use a TSharedPtr of one mode with a type which inherits TSharedFromThis of another mode.");
1826
1827 if( !WeakThis.IsValid() )
1828 {
1829 WeakThis = TSharedRef< ObjectType, Mode >( *InSharedRef, InObject );
1830 }
1831 }
1832
1841 {
1842 return WeakThis.IsValid();
1843 }
1844
1845protected:
1846
1849 {
1850#ifndef UE_HEADER_UNITS
1851 // Cause a compile error if ObjectType is a UObject.
1852 int32 UObjectTestOverload(const volatile UObject*);
1854 static_assert(sizeof(UObjectTestOverload((ObjectType*)nullptr)) == sizeof(int16), "TSharedFromThis is not supported on UObjects");
1855#endif
1856 }
1857
1860
1863 {
1864 return *this;
1865 }
1866
1869 {
1870 }
1871
1872private:
1873
1876 mutable TWeakPtr< ObjectType, Mode > WeakThis;
1877};
1878
1879
1885template< class CastToType, class CastFromType, ESPMode Mode >
1890
1891
1897template< class CastToType, class CastFromType, ESPMode Mode >
1902
1903
1909template< class CastToType, class CastFromType, ESPMode Mode >
1914
1915
1921template< class CastToType, class CastFromType, ESPMode Mode >
1926
1927
1933template< class CastToType, class CastFromType, ESPMode Mode >
1938
1939
1945// NOTE: The following is an Unreal extension to standard shared_ptr behavior
1946template< class ObjectType >
1948{
1950 // If you get an 'ambiguous call' compile error in this function, it means you have multiple //
1951 // TSharedFromThis bases in your inheritance hierarchy. This is not supported. //
1953
1955 {
1956 // If this goes off, you should probably be using Ptr->AsShared() or Ptr->AsWeak() instead.
1957 checkf(!InObject || !InObject->DoesSharedInstanceExist(), TEXT("Trying to share an already-shared object"));
1958 }
1959
1961}
1962
1963
1969// NOTE: The following is an Unreal extension to standard shared_ptr behavior
1970template< class ObjectType, class DeleterType >
1972{
1974 // If you get an 'ambiguous call' compile error in this function, it means you have multiple //
1975 // TSharedFromThis bases in your inheritance hierarchy. This is not supported. //
1977
1979 {
1980 // If this goes off, you should probably be using Ptr->AsShared() or Ptr->AsWeak() instead.
1981 checkf(!InObject || !InObject->DoesSharedInstanceExist(), TEXT("Trying to share an already-shared object"));
1982 }
1983
1985}
1986
2008template <typename InObjectType, ESPMode InMode = ESPMode::ThreadSafe, typename... InArgTypes>
2010{
2011 SharedPointerInternals::TIntrusiveReferenceController<InObjectType, InMode>* Controller = SharedPointerInternals::NewIntrusiveReferenceController<InMode, InObjectType>(Forward<InArgTypes>(Args)...);
2012 return UE::Core::Private::MakeSharedRef<InObjectType, InMode>(Controller->GetObjectPtr(), (SharedPointerInternals::TReferenceControllerBase<InMode>*)Controller);
2013}
2014
2015
2020template <class Type>
2022{
2024 for (int32 i = 0; i < PointerArray.Num(); ++i)
2025 {
2026 if (PointerArray[i].IsValid())
2027 {
2029 }
2030 }
2032}
2033
2034
2039template <class KeyType, class ValueType>
2040inline void CleanupPointerMap(TMap< TWeakPtr<KeyType>, ValueType >& PointerMap)
2041{
2042 TMap< TWeakPtr<KeyType>, ValueType > NewMap;
2043 for (typename TMap< TWeakPtr<KeyType>, ValueType >::TConstIterator Op(PointerMap); Op; ++Op)
2044 {
2045 const TWeakPtr<KeyType> WeakPointer = Op.Key();
2046 if (WeakPointer.IsValid())
2047 {
2048 NewMap.Add(WeakPointer, Op.Value());
2049 }
2050 }
2051 PointerMap = NewMap;
2052}
2053
2061template <typename ObjectType, ESPMode Mode>
2063{
2064 return ::PointerHash( &InSharedRef.Get() );
2065}
2066
2074template <typename ObjectType, ESPMode Mode>
2076{
2077 return ::PointerHash( InSharedPtr.Get() );
2078}
2079
2087template <typename ObjectType, ESPMode Mode>
2089{
2090 return InWeakPtr.GetWeakPtrTypeHash();
2091}
2092
2093// Shared pointer testing
2094#include "Templates/SharedPointerTesting.inl" // IWYU pragma: export
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
void EnsureRetrievingVTablePtrDuringCtor(const TCHAR *CtorSignature)
Definition CoreMisc.cpp:436
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
#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
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
#define UE_REWRITE
Definition Platform.h:747
constexpr bool TIsTSharedPtr_V
Definition SharedPointer.h:1262
TSharedRef< InObjectType, InMode > MakeShared(InArgTypes &&... Args)
Definition SharedPointer.h:2009
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > ConstCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:1910
constexpr bool TIsTSharedRef_V
Definition SharedPointer.h:673
SharedPointerInternals::TRawPtrProxy< ObjectType > MakeShareable(ObjectType *InObject)
Definition SharedPointer.h:1947
constexpr bool TIsTWeakPtr_V
Definition SharedPointer.h:1617
void CleanupPointerMap(TMap< TWeakPtr< KeyType >, ValueType > &PointerMap)
Definition SharedPointer.h:2040
UE_FORCEINLINE_HINT TWeakPtr< CastToType, Mode > StaticCastWeakPtr(TWeakPtr< CastFromType, Mode > const &InWeakPtr)
Definition SharedPointer.h:1898
UE_FORCEINLINE_HINT TSharedPtr< CastToType, Mode > ConstCastSharedPtr(TSharedPtr< CastFromType, Mode > const &InSharedPtr)
Definition SharedPointer.h:1922
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 GetTypeHash(const TSharedRef< ObjectType, Mode > &InSharedRef)
Definition SharedPointer.h:2062
UE_FORCEINLINE_HINT TWeakPtr< CastToType, Mode > ConstCastWeakPtr(TWeakPtr< CastFromType, Mode > const &InWeakPtr)
Definition SharedPointer.h:1934
void CleanupPointerArray(TArray< TWeakPtr< Type > > &PointerArray)
Definition SharedPointer.h:2021
UE_FORCEINLINE_HINT TSharedPtr< CastToType, Mode > StaticCastSharedPtr(TSharedPtr< CastFromType, Mode > const &InSharedPtr)
Definition SharedPointer.h:1886
#define PGO_LINK_DISABLE_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:71
#define PGO_LINK_ENABLE_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:75
void Init()
Definition LockFreeList.h:4
#define DECLARE_TEMPLATE_INTRINSIC_TYPE_LAYOUT(TemplatePrefix, T)
Definition MemoryLayout.h:661
const bool
Definition NetworkReplayStreaming.h:178
#define UE_REQUIRES(...)
Definition Requires.h:86
#define UE_REQUIRES_EXPR(...)
Definition Requires.h:89
ESPMode
Definition SharedPointerFwd.h:12
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MemoryImageWriter.h:14
CORE_API uint32 WriteBytes(const void *Data, uint32 Size)
Definition MemoryImage.cpp:2143
Definition SharedPointerInternals.h:535
Definition SharedPointerInternals.h:715
Definition SharedPointerInternals.h:400
Definition SharedPointerInternals.h:45
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition Array.h:64
Definition UnrealString.h.inl:34
Definition SharedPointer.h:1640
TSharedRef< ObjectType, Mode > AsShared()
Definition SharedPointer.h:1650
TWeakPtr< SubobjectType, Mode > AsWeakSubobject(SubobjectType *SubobjectPtr) const
Definition SharedPointer.h:1764
TSharedRef< SubobjectType, Mode > AsSharedSubobject(SubobjectType *SubobjectPtr) const
Definition SharedPointer.h:1706
static UE_FORCEINLINE_HINT TSharedRef< OtherType const, Mode > SharedThis(const OtherType *ThisPtr)
Definition SharedPointer.h:1794
TWeakPtr< ObjectType, Mode > AsWeak()
Definition SharedPointer.h:1718
UE_FORCEINLINE_HINT TSharedFromThis & operator=(TSharedFromThis const &)
Definition SharedPointer.h:1862
TSharedFromThis()
Definition SharedPointer.h:1848
TSharedFromThis(TSharedFromThis const &)
Definition SharedPointer.h:1859
void UpdateWeakReferenceInternal(TSharedRef< SharedRefType, SharedPtrMode > const *InSharedRef, OtherType *InObject) const
Definition SharedPointer.h:1823
TSharedRef< ObjectType const, Mode > AsShared() const
Definition SharedPointer.h:1677
TWeakPtr< ObjectType const, Mode > AsWeak() const
Definition SharedPointer.h:1736
UE_FORCEINLINE_HINT bool DoesSharedInstanceExist() const
Definition SharedPointer.h:1840
void UpdateWeakReferenceInternal(TSharedPtr< SharedPtrType, SharedPtrMode > const *InSharedPtr, OtherType *InObject) const
Definition SharedPointer.h:1807
static UE_FORCEINLINE_HINT TSharedRef< OtherType, Mode > SharedThis(OtherType *ThisPtr)
Definition SharedPointer.h:1780
~TSharedFromThis()
Definition SharedPointer.h:1868
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT TWeakPtr< ObjectType, Mode > ToWeakPtr() const
Definition SharedPointer.h:1055
DummyObjectType & operator*() const
Definition SharedPointer.h:1099
TSharedPtr(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
Definition SharedPointer.h:797
UE_FORCEINLINE_HINT int32 GetSharedReferenceCount() const
Definition SharedPointer.h:1131
TSharedPtr(SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
Definition SharedPointer.h:757
TSharedPtr(TSharedPtr const &InSharedPtr)
Definition SharedPointer.h:822
bool UEOpEquals(FIntrusiveUnsetOptionalState) const
Definition SharedPointer.h:1158
friend class TSharedPtr
Definition SharedPointer.h:1242
TSharedPtr(FIntrusiveUnsetOptionalState)
Definition SharedPointer.h:1154
TSharedPtr(TSharedPtr< OtherType, Mode > &&OtherSharedPtr, ObjectType *InObject)
Definition SharedPointer.h:906
UE_REWRITE bool UEOpEquals(TYPE_OF_NULLPTR) const
Definition SharedPointer.h:1178
TSharedPtr(TSharedPtr< OtherType, Mode > const &InSharedPtr, SharedPointerInternals::FConstCastTag)
Definition SharedPointer.h:878
static constexpr ESPMode Mode
Definition SharedPointer.h:695
UE_FORCEINLINE_HINT ObjectType * Get() const
Definition SharedPointer.h:1065
UE_REWRITE bool UEOpEquals(const TWeakPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:1173
TSharedPtr(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
Definition SharedPointer.h:777
TSharedPtr(TSharedPtr &&InSharedPtr)
Definition SharedPointer.h:828
bool UEOpLessThan(const TSharedPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:1184
TSharedRef< ObjectType, Mode > ToSharedRef() &&
Definition SharedPointer.h:1042
TSharedPtr & operator=(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
Definition SharedPointer.h:997
TSharedPtr(TSharedPtr< OtherType, Mode > const &InSharedPtr, SharedPointerInternals::FStaticCastTag)
Definition SharedPointer.h:863
bool UEOpEquals(const TSharedPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:1167
TSharedPtr(OtherType *InObject)
Definition SharedPointer.h:717
TSharedRef< ObjectType, Mode > ToSharedRef() const &
Definition SharedPointer.h:1028
static constexpr bool bHasIntrusiveUnsetOptionalState
Definition SharedPointer.h:1151
UE_FORCEINLINE_HINT bool IsUnique() const
Definition SharedPointer.h:1143
UE_FORCEINLINE_HINT void Reset()
Definition SharedPointer.h:1120
TSharedPtr(TSharedPtr< OtherType, Mode > const &InSharedPtr)
Definition SharedPointer.h:816
ObjectType ElementType
Definition SharedPointer.h:694
TSharedPtr(OtherType *InObject, DeleterType &&InDeleter)
Definition SharedPointer.h:738
ObjectType * operator->() const
Definition SharedPointer.h:1110
TSharedPtr & operator=(SharedPointerInternals::FNullTag *)
Definition SharedPointer.h:932
TSharedPtr(TSharedPtr< OtherType, Mode > const &OtherSharedPtr, ObjectType *InObject)
Definition SharedPointer.h:892
PGO_LINK_DISABLE_WARNINGS TSharedPtr & operator=(TSharedPtr &&InSharedPtr)
Definition SharedPointer.h:954
TSharedPtr(TSharedRef< OtherType, Mode > const &InSharedRef)
Definition SharedPointer.h:846
UE_FORCEINLINE_HINT const bool IsValid() const
Definition SharedPointer.h:1085
PGO_LINK_ENABLE_WARNINGS TSharedPtr & operator=(SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
Definition SharedPointer.h:978
TSharedPtr(TSharedRef< OtherType, Mode > const &OtherSharedRef, ObjectType *InObject)
Definition SharedPointer.h:921
TSharedPtr(SharedPointerInternals::FNullTag *=nullptr)
Definition SharedPointer.h:701
TSharedPtr & operator=(TSharedPtr const &InSharedPtr)
Definition SharedPointer.h:945
TSharedPtr & operator=(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
Definition SharedPointer.h:1016
Definition SharedPointer.h:153
TSharedRef(FIntrusiveUnsetOptionalState)
Definition SharedPointer.h:538
TSharedRef(TSharedRef const &InSharedRef)
Definition SharedPointer.h:347
TSharedRef(SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
Definition SharedPointer.h:221
bool UEOpLessThan(const TSharedRef< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:571
TSharedRef & operator=(SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
Definition SharedPointer.h:393
TSharedRef(TSharedRef &&InSharedRef)
Definition SharedPointer.h:352
ObjectType & operator*() const
Definition SharedPointer.h:486
TSharedRef(TSharedRef< OtherType, Mode > const &OtherSharedRef, ObjectType *InObject)
Definition SharedPointer.h:338
UE_FORCEINLINE_HINT bool IsUnique() const
Definition SharedPointer.h:527
TSharedRef(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
Definition SharedPointer.h:246
friend class TSharedRef
Definition SharedPointer.h:635
UE_FORCEINLINE_HINT TSharedPtr< ObjectType, Mode > ToSharedPtr() const
Definition SharedPointer.h:454
TSharedRef(OtherType *InObject)
Definition SharedPointer.h:172
TSharedRef(TSharedRef< OtherType, Mode > const &InSharedRef, SharedPointerInternals::FStaticCastTag)
Definition SharedPointer.h:309
TSharedRef & operator=(TSharedRef &&InSharedRef)
Definition SharedPointer.h:375
TSharedRef & operator=(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
Definition SharedPointer.h:439
TSharedRef & operator=(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
Definition SharedPointer.h:416
ObjectType ElementType
Definition SharedPointer.h:157
static constexpr bool bHasIntrusiveUnsetOptionalState
Definition SharedPointer.h:535
TSharedRef(SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
Definition SharedPointer.h:271
TSharedRef(TSharedRef< OtherType, Mode > const &InSharedRef)
Definition SharedPointer.h:294
static constexpr ESPMode Mode
Definition SharedPointer.h:158
ObjectType * operator->() const
Definition SharedPointer.h:498
ObjectType & Get() const
Definition SharedPointer.h:474
UE_FORCEINLINE_HINT int32 GetSharedReferenceCount() const
Definition SharedPointer.h:511
bool UEOpEquals(const TWeakPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:565
bool UEOpEquals(const TSharedPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:557
TSharedRef()
Definition SharedPointer.h:202
bool UEOpEquals(const TSharedRef< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:551
TSharedRef(OtherType *InObject, DeleterType &&InDeleter)
Definition SharedPointer.h:190
TSharedRef(TSharedRef< OtherType, Mode > const &InSharedRef, SharedPointerInternals::FConstCastTag)
Definition SharedPointer.h:324
UE_FORCEINLINE_HINT TWeakPtr< ObjectType, Mode > ToWeakPtr() const
Definition SharedPointer.h:464
bool UEOpEquals(FIntrusiveUnsetOptionalState) const
Definition SharedPointer.h:542
TSharedRef & operator=(TSharedRef const &InSharedRef)
Definition SharedPointer.h:368
Definition SharedPointer.h:1295
UE_FORCEINLINE_HINT bool HasSameObject(const void *InOtherPtr) const
Definition SharedPointer.h:1552
TWeakPtr(TWeakPtr< OtherType, Mode > const &InWeakPtr, SharedPointerInternals::FConstCastTag)
Definition SharedPointer.h:1363
UE_FORCEINLINE_HINT TSharedPtr< ObjectType, Mode > Pin() const &
Definition SharedPointer.h:1512
UE_FORCEINLINE_HINT TSharedPtr< ObjectType, Mode > Pin() &&
Definition SharedPointer.h:1525
TWeakPtr & operator=(TSharedPtr< OtherType, Mode > const &InSharedPtr)
Definition SharedPointer.h:1497
TWeakPtr(TSharedRef< OtherType, Mode > const &InSharedRef)
Definition SharedPointer.h:1318
friend class TWeakPtr
Definition SharedPointer.h:1599
TWeakPtr & operator=(TWeakPtr< OtherType, Mode > const &InWeakPtr)
Definition SharedPointer.h:1452
bool UEOpLessThan(const TWeakPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:1592
bool UEOpEquals(FIntrusiveUnsetOptionalState) const
Definition SharedPointer.h:1572
static constexpr bool bHasIntrusiveUnsetOptionalState
Definition SharedPointer.h:1565
TWeakPtr(TWeakPtr &&InWeakPtr)
Definition SharedPointer.h:1402
UE_FORCEINLINE_HINT uint32 GetWeakPtrTypeHash() const
Definition SharedPointer.h:1557
TWeakPtr(TWeakPtr< OtherType, Mode > &&InWeakPtr)
Definition SharedPointer.h:1389
TWeakPtr(TWeakPtr< OtherType, Mode > const &InWeakPtr)
Definition SharedPointer.h:1379
TWeakPtr(TWeakPtr< OtherType, Mode > const &InWeakPtr, SharedPointerInternals::FStaticCastTag)
Definition SharedPointer.h:1348
TWeakPtr(TSharedPtr< OtherType, Mode > const &InSharedPtr)
Definition SharedPointer.h:1333
TWeakPtr(FIntrusiveUnsetOptionalState)
Definition SharedPointer.h:1568
UE_FORCEINLINE_HINT bool IsValid() const
Definition SharedPointer.h:1535
UE_FORCEINLINE_HINT void Reset()
Definition SharedPointer.h:1544
TWeakPtr & operator=(TSharedRef< OtherType, Mode > const &InSharedRef)
Definition SharedPointer.h:1481
bool UEOpEquals(const TWeakPtr< OtherType, Mode > &Rhs) const
Definition SharedPointer.h:1581
UE_REWRITE bool UEOpEquals(TYPE_OF_NULLPTR) const
Definition SharedPointer.h:1586
TWeakPtr & operator=(TWeakPtr &&InWeakPtr)
Definition SharedPointer.h:1431
TWeakPtr(TWeakPtr const &InWeakPtr)
Definition SharedPointer.h:1396
TWeakPtr & operator=(TWeakPtr const &InWeakPtr)
Definition SharedPointer.h:1424
TWeakPtr & operator=(SharedPointerInternals::FNullTag *)
Definition SharedPointer.h:1413
static constexpr ESPMode Mode
Definition SharedPointer.h:1298
ObjectType ElementType
Definition SharedPointer.h:1297
TWeakPtr & operator=(TWeakPtr< OtherType, Mode > &&InWeakPtr)
Definition SharedPointer.h:1463
TWeakPtr(SharedPointerInternals::FNullTag *=nullptr)
Definition SharedPointer.h:1302
Definition Object.h:95
Definition Array.h:3955
UE_NODEBUG void IntrinsicWriteMemoryImage(FMemoryImageWriter &Writer, const TArray< T, AllocatorType > &Object, const FTypeLayoutDesc &)
Definition Array.h:3957
Definition SharedPointerInternals.h:32
void EnableSharedFromThis(SharedPtrType *InSharedPtrOrRef, ObjectType const *InObject)
Definition SharedPointerInternals.h:864
implementation
Definition PlayInEditorLoadingScope.h:8
UE_FORCEINLINE_HINT TSharedRef< ObjectType, Mode > MakeSharedRef(ObjectType *InObject, SharedPointerInternals::TReferenceControllerBase< Mode > *InSharedReferenceCount)
Definition SharedPointer.h:138
Definition IntrusiveUnsetOptionalState.h:71
Definition MemoryLayout.h:108
Definition SharedPointerInternals.h:38
Definition SharedPointerInternals.h:41
Definition SharedPointerInternals.h:37
Definition SharedPointerInternals.h:506
Definition SharedPointerInternals.h:484
Definition UnrealTypeTraits.h:267
Definition UnrealTypeTraits.h:283
Definition UnrealTypeTraits.h:181
@ Value
Definition UnrealTypeTraits.h:182
Definition UnrealTypeTraits.h:172