Language:
Discover
By Skill Level
By Category

TSharedPtr

Choose your OS:

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

(
    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.

Public function

TSharedPtr

(
    OtherType* InObject,
    DeleterType&& InDeleter
)

Constructs a shared pointer that owns the specified object.

Functions

Name Description

Public function

ObjectType &...

 

Get()

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

Public function

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 bool

 

IsUnique()

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

Public function

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.

Operators

Name Description

Public function

 

operator bool()

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

Public function

FMakeReferen ...

 

operator*()

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

Public function

TSharedPtr &

 

operator=

(
    TSharedPtr && InSharedPtr
)

Public function

TSharedPtr &

 

operator=

(
    TSharedPtr const& InSharedPtr
)

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

Public function

TSharedPtr &

 

operator=

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

Public function

TSharedPtr &

 

operator=

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

Public function

ObjectType &...

 

operator->()

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

References

Module

Core

Header

Runtime/Core/Public/Templates/SharedPointer.h