TSharedRef

[TSharedRef](API\Runtime\Core\Templates\TSharedRef) is a non-nullable, non-intrusive reference-counted authoritative object reference.

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

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
)

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

Public function

TSharedRef

Constructs a shared reference using a proxy reference to a raw pointer.

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 Const

ObjectType &

 

Get()

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

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.

Operators

Name Description

Public function Const

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=

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

Public function Const

ObjectType &...

 

operator->()

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

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