TSharedPtr

[TSharedPtr](API\Runtime\Core\Templates\TSharedPtr) is a non-intrusive reference-counted authoritative object pointer.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Templates/SharedPointer.h

Include

#include "Templates/SharedPointer.h"

Syntax

template<class ObjectType, ESPMode Mode>
class TSharedPtr

Remarks

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.

Constructors

Name Description

Public function

TSharedPtr

NOTE: FNullTag parameter is an Unreal extension to standard shared_ptr behavior.

Public function

TSharedPtr

(
    OtherType* InObject,
    DeleterType&& InDeleter
)

Constructs a shared pointer that owns the specified object.

Public function

TSharedPtr

(
    TSharedPtr< OtherType, Mode > const...,
    SharedPointerInternals::FStaticCast...
)

Special constructor used internally to statically cast one shared pointer type to another.

Public function

TSharedPtr

(
    TSharedPtr< OtherType, Mode > const...,
    SharedPointerInternals::FConstCastT...
)

Special constructor used internally to cast a 'const' shared pointer a 'mutable' pointer.

Public function

TSharedPtr

(
    TSharedPtr< OtherType, Mode > const...,
    ObjectType* InObject
)

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.

Public function

TSharedPtr

(
    TSharedPtr< OtherType, Mode >&& Ot...,
    ObjectType* InObject
)

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.

Public function

TSharedPtr

(
    TSharedRef< OtherType, Mode > const...,
    ObjectType* InObject
)

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.

Public function

TSharedPtr

(
    OtherType* InObject
)

Constructs a shared pointer that owns the specified object.

Public function

TSharedPtr

NOTE: The following is an Unreal extension to standard shared_ptr behavior.

Public function

TSharedPtr

(
    TSharedPtr< OtherType, Mode > const...
)

Constructs a shared pointer as a shared reference to an existing shared pointer's object.

Public function

TSharedPtr

(
    TSharedPtr const& InSharedPtr
)

Public function

TSharedPtr

(
    TSharedPtr&& InSharedPtr
)

Public function

TSharedPtr

(
    TSharedRef< OtherType, Mode > const...
)

NOTE: The following is an Unreal extension to standard shared_ptr behavior.

Functions

Name Description

Public function Const

ObjectType &...

 

Get()

Returns the object referenced by this pointer, or nullptr if no object is reference

Public function Const

const 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!

Public function Const

const bool

 

IsUnique()

Returns true if this is the only shared reference to this object.

Public function Const

const bool

 

IsValid()

Checks to see if this shared pointer is actually pointing to an object

Public function

void

 

Reset()

Resets this shared pointer, removing a reference to the object.

Public function

TSharedRef< ...

 

ToSharedRef()

NOTE: The following is an Unreal extension to standard shared_ptr behavior.

Public function Const

TSharedRef< ...

 

ToSharedRef()

NOTE: The following is an Unreal extension to standard shared_ptr behavior.

Operators

Name Description

Public function Const

 

operator bool()

Checks to see if this shared pointer is actually pointing to an object

Public function Const

FMakeReferen...

 

operator*()

Dereference operator returns a reference to the object this shared pointer points to

Public function

TSharedPtr &

 

operator=

NOTE: The following is an Unreal extension to standard shared_ptr behavior.

Public function

TSharedPtr &

 

operator=

(
    TSharedPtr const& InSharedPtr
)

Assignment operator replaces this shared pointer with the specified shared pointer.

Public function

TSharedPtr &

 

operator=

(
    TSharedPtr&& InSharedPtr
)

Public function

TSharedPtr &

 

operator=

NOTE: The following is an Unreal extension to standard shared_ptr behavior.

Public function Const

ObjectType &...

 

operator->()

Arrow operator returns a pointer to the object this shared pointer references

Typedefs

Name

Description

ElementType

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss