TSharedRef

NOTE: [TSharedRef](API\Runtime\Core\Templates\TSharedRef) is an Unreal extension to standard smart pointer feature set.

Inheritance Hierarchy

TSharedRef

TGLTFSharedArray

References

Module

Core

Header

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

Include

#include "Templates/SharedPointer.h"

Syntax

template<class ObjectType, ESPMode InMode>
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. By default, thread safety features are turned on. (Mode = ESPMode::ThreadSafe). If you need more concerned with performance of ref-counting, you should use ESPMode::NotThreadSafe.

Constructors

Name Description

Public function

TSharedRef()

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

Public function

TSharedRef

(
    OtherType* InObject,
    DeleterType&& InDeleter
)

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

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

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

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

(
    FIntrusiveUnsetOptionalState
)

Functions

Name Description

Public function Const

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.

Public function Const

TSharedPtr< ...

 

ToSharedPtr()

Converts a shared reference to a shared pointer.

Public function Const

TWeakPtr< Ob...

 

ToWeakPtr()

Converts a shared reference to a weak ptr.

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=

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

Public function

TSharedRef &

 

operator=

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

Public function

TSharedRef &

 

operator=

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

Public function

TSharedRef &

 

operator=

(
    TSharedRef&& InSharedRef
)

Public function

void

 

operator=

(
    FIntrusiveUnsetOptionalState
)

Public function

TSharedRef &

 

operator=

(
    TSharedRef const& InSharedRef
)

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

Public function Const

bool

 

operator==

(
    FIntrusiveUnsetOptionalState
)

Public function Const

ObjectType &...

 

operator->()

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

Typedefs

Constants

Name

Description

bHasIntrusiveUnsetOptionalState

Start - intrusive TOptional state //.

Mode

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