Navigation
API > API/Runtime > API/Runtime/Core
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 are more concerned with performance of ref-counting, you should use ESPMode::NotThreadSafe.
| Name | TSharedRef |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Templates/SharedPointer.h |
| Include Path | #include "Templates/SharedPointer.h" |
Syntax
template<class ObjectType, ESPMode InMode>
class TSharedRef
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSharedRef
(
TSharedRef< OtherType, Mode > const& InSharedRef, |
Special constructor used internally to cast a 'const' shared reference a 'mutable' reference. | Templates/SharedPointer.h | |
TSharedRef
(
TSharedRef< OtherType, Mode > const& InSharedRef, |
Special constructor used internally to statically cast one shared reference type to another. | Templates/SharedPointer.h | |
TSharedRef
(
OtherType* InObject, |
Constructs a shared reference that owns the specified object. Must not be nullptr. | Templates/SharedPointer.h | |
TSharedRef
(
TSharedPtr< OtherType, Mode >&& InSharedPtr |
Templates/SharedPointer.h | ||
TSharedRef
(
TSharedPtr< OtherType, Mode > const& InSharedPtr |
Converts a shared pointer to a shared reference. | Templates/SharedPointer.h | |
| Templates/SharedPointer.h | |||
TSharedRef
(
TSharedRef&& InSharedRef |
Templates/SharedPointer.h | ||
TSharedRef () |
Constructs default shared reference that owns the default object for specified type. | Templates/SharedPointer.h | |
TSharedRef
(
TSharedRef< OtherType, Mode > const& InSharedRef |
Constructs a shared reference as a reference to an existing shared reference's object. | Templates/SharedPointer.h | |
TSharedRef
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType >&& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef
(
SharedPointerInternals::TRawPtrProxy< OtherType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef
(
OtherType* InObject |
NOTE: TSharedRef has no default constructor as it does not support empty references. | Templates/SharedPointer.h | |
TSharedRef
(
TSharedRef< OtherType, Mode > const& OtherSharedRef, |
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. | Templates/SharedPointer.h | |
TSharedRef
(
TSharedRef const& InSharedRef |
Templates/SharedPointer.h | ||
TSharedRef
(
ObjectType* InObject, |
Templates/SharedPointer.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementType | ObjectType | Templates/SharedPointer.h | |
| IntrusiveUnsetOptionalStateType | TSharedRef | Templates/SharedPointer.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| bHasIntrusiveUnsetOptionalState | bool | Start - intrusive TOptional |
Templates/SharedPointer.h |
| Mode | ESPMode | Templates/SharedPointer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Object | ObjectType * | The object we're holding a reference to. Can be nullptr. | Templates/SharedPointer.h | |
| SharedReferenceCount | SharedPointerInternals::FSharedReferencer< Mode > | Interface to the reference counter for this object. | Templates/SharedPointer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ObjectType & Get() |
Returns a C++ reference to the object this shared reference is referencing | Templates/SharedPointer.h | |
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! | Templates/SharedPointer.h | |
bool IsUnique () |
Returns true if this is the only shared reference to this object. | Templates/SharedPointer.h | |
TSharedPtr< ObjectType, Mode > ToSharedPtr() |
Converts a shared reference to a shared pointer. | Templates/SharedPointer.h | |
TWeakPtr< ObjectType, Mode > ToWeakPtr() |
Converts a shared reference to a weak ptr. | Templates/SharedPointer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ObjectType & operator*() |
Dereference operator returns a reference to the object this shared pointer points to | Templates/SharedPointer.h | |
TSharedRef & operator=
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType >&& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef & operator=
(
SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef & operator=
(
SharedPointerInternals::TRawPtrProxy< OtherType > const& InRawPtrProxy |
NOTE: The following is an Unreal extension to standard shared_ptr behavior. | Templates/SharedPointer.h | |
TSharedRef & operator=
(
TSharedRef&& InSharedRef |
Templates/SharedPointer.h | ||
TSharedRef & operator=
(
TSharedRef const& InSharedRef |
Assignment operator replaces this shared reference with the specified shared reference. | Templates/SharedPointer.h | |
bool operator==
(
FIntrusiveUnsetOptionalState |
Templates/SharedPointer.h | ||
ObjectType * operator->() |
Arrow operator returns a pointer to this shared reference's object | Templates/SharedPointer.h |