Navigation
API > API/Runtime > API/Runtime/Core
TSharedPtr is a non-intrusive reference-counted authoritative object pointer. This shared pointer will be conditionally thread-safe when the optional Mode template argument is set to ThreadSafe.
| Name | TSharedPtr |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Templates/SharedPointer.h |
| Include Path | #include "Templates/SharedPointer.h" |
Syntax
template<class ObjectType, ESPMode InMode>
class TSharedPtr
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSharedPtr
(
SharedPointerInternals::FSharedReferencer< Mode > InSharedReferenceCount, |
Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. | Templates/SharedPointer.h | |
TSharedPtr
(
OtherType* InObject, |
Constructs a shared pointer that owns the specified object. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedPtr< OtherType, Mode > const& InSharedPtr, |
Special constructor used internally to statically cast one shared pointer type to another. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedPtr< OtherType, Mode >&& InSharedPtr, |
Templates/SharedPointer.h | ||
TSharedPtr
(
TSharedPtr< OtherType, Mode > const& InSharedPtr, |
Special constructor used internally to cast a 'const' shared pointer a 'mutable' pointer. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedPtr< OtherType, Mode >&& OtherSharedPtr, |
Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedPtr< OtherType, Mode > const& OtherSharedPtr, |
Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedRef< OtherType, Mode > const& OtherSharedRef, |
Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. | Templates/SharedPointer.h | |
TSharedPtr
(
TWeakPtr< OtherType, Mode >&& InWeakPtr |
Constructs a shared pointer from a weak pointer, allowing you to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the shared pointer will not be valid. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedPtr< OtherType, Mode >&& InSharedPtr, |
Templates/SharedPointer.h | ||
TSharedPtr
(
TWeakPtr< OtherType, Mode > const& InWeakPtr |
Constructs a shared pointer from a weak pointer, allowing you to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the shared pointer will not be valid. | Templates/SharedPointer.h | |
TSharedPtr
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedRef< OtherType, Mode > const& InSharedRef |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedPtr
(
TSharedPtr&& InSharedPtr |
Templates/SharedPointer.h | ||
TSharedPtr
(
TSharedPtr const& InSharedPtr |
Templates/SharedPointer.h | ||
TSharedPtr
(
TSharedPtr< OtherType, Mode > const& InSharedPtr |
Constructs a shared pointer as a shared reference to an existing shared pointer's object. | Templates/SharedPointer.h | |
TSharedPtr
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType >&& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedPtr
(
SharedPointerInternals::TRawPtrProxy< OtherType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedPtr
(
OtherType* InObject |
Constructs a shared pointer that owns the specified object. | Templates/SharedPointer.h | |
| NOTE: FNullTag parameter is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | ||
| Templates/SharedPointer.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementType | ObjectType | Templates/SharedPointer.h | |
| IntrusiveUnsetOptionalStateType | TSharedPtr | Templates/SharedPointer.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| AutoRTFMReturnFromOpenMode | AutoRTFM::EReturnFromOpenMode | TSharedPtr can be returned from AutoRTFM::Open() via a copy-construction in the closed. | Templates/SharedPointer.h |
| bHasIntrusiveUnsetOptionalState | bool | Start - intrusive TOptional |
Templates/SharedPointer.h |
| Mode | ESPMode | Templates/SharedPointer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Object | ObjectType * | The object we're holding a reference to. Can be nullptr. | Templates/SharedPointer.h | |
| SharedReferenceCount | SharedPointerInternals::FSharedReferencer< Mode > | Interface to the reference counter for this object. | Templates/SharedPointer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ObjectType * Get() |
Returns the object referenced by this pointer, or nullptr if no object is reference | Templates/SharedPointer.h | |
int32 GetSharedReferenceCount() |
Returns the number of shared references to this object (including this reference.) IMPORTANT: Not necessarily fast! Should only be used for debugging purposes! | Templates/SharedPointer.h | |
bool IsUnique () |
Returns true if this is the only shared reference to this object. | Templates/SharedPointer.h | |
const bool IsValid() |
Checks to see if this shared pointer is actually pointing to an object | Templates/SharedPointer.h | |
void Reset () |
Resets this shared pointer, removing a reference to the object. | Templates/SharedPointer.h | |
TSharedRef< ObjectType, Mode > ToSharedRef () |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef< ObjectType, Mode > ToSharedRef () |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TWeakPtr< ObjectType, Mode > ToWeakPtr() |
Converts a shared pointer to a weak ptr. | Templates/SharedPointer.h | |
bool UEOpEquals
(
const TWeakPtr< OtherType, Mode >& Rhs |
Templates/SharedPointer.h | ||
bool UEOpEquals
(
FIntrusiveUnsetOptionalState |
Templates/SharedPointer.h | ||
bool UEOpEquals
(
const TSharedPtr< OtherType, Mode >& Rhs |
End - intrusive TOptional |
Templates/SharedPointer.h | |
bool UEOpEquals
(
TYPE_OF_NULLPTR |
Templates/SharedPointer.h | ||
bool UEOpLessThan
(
const TSharedPtr< OtherType, Mode >& Rhs |
Templates/SharedPointer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
operator bool() |
Checks to see if this shared pointer is actually pointing to an object | Templates/SharedPointer.h | |
std::add_lvalue_reference_t< ObjectType > operator*() |
Dereference operator returns a reference to the object this shared pointer points to | Templates/SharedPointer.h | |
TSharedPtr & operator=
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType >&& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedPtr & operator=
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedPtr & operator=
(
TSharedPtr&& InSharedPtr |
Disable false positive buffer overrun warning during pgo linking step. | Templates/SharedPointer.h | |
TSharedPtr & operator=
(
TSharedPtr const& InSharedPtr |
Assignment operator replaces this shared pointer with the specified shared pointer. | Templates/SharedPointer.h | |
TSharedPtr & operator=
(
SharedPointerInternals::TRawPtrProxy< OtherType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
| NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | ||
ObjectType * operator->() |
Arrow operator returns a pointer to the object this shared pointer references | Templates/SharedPointer.h |