Language:
Discover
By Skill Level
By Category

TSharedRef

Choose your OS:

Syntax

template<class ObjectType, ESPMode Mode>
class TSharedRef

Remarks

TSharedRef is a non-nullable, non-intrusive reference-counted authoritative object reference.

This shared reference will be conditionally thread-safe when the optional Mode template argument is set to ThreadSafe.

Forward declarations. Note that in the interest of fast performance, thread safety features are mostly turned off (Mode = ESPMode::Fast ). If you need to access your object on multiple threads, you should use ESPMode::ThreadSafe !

Constructors

Name Description

Public function

TSharedRef()

Constructs default shared reference that owns the default object for specified type.

Public function

TSharedRef

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

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

Public function

TSharedRef

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

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

Public function

TSharedRef

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

Aliasing constructor used to create a shared reference which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

Public function

TSharedRef

(
    OtherType* InObject
)

NOTE: TSharedRef has no default constructor as it does not support empty references.

Public function

TSharedRef

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

Public function

TSharedRef

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

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

Public function

TSharedRef

(
    TSharedRef const& InSharedRef
)

Public function

TSharedRef

(
    TSharedRef && InSharedRef
)

Public function

TSharedRef

(
    OtherType* InObject,
    DeleterType&& InDeleter
)

Constructs a shared reference that owns the specified object. Must not be nullptr.

Functions

Name Description

Public function

ObjectType &

 

Get()

Returns a C++ reference to the object this shared reference is referencing

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.

Operators

Name Description

Public function

ObjectType &

 

operator*()

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

Public function

TSharedRef &

 

operator=

(
    TSharedRef const& InSharedRef
)

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

Public function

TSharedRef &

 

operator=

(
    TSharedRef && InSharedRef
)

Public function

TSharedRef &

 

operator=

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

Public function

ObjectType &...

 

operator->()

Arrow operator returns a pointer to this shared reference's object

References

Module

Core

Header

Runtime/Core/Public/Templates/SharedPointer.h