TWeakPtr

[TWeakPtr](API\Runtime\Core\Templates\TWeakPtr) is a non-intrusive reference-counted weak object pointer.

References

Module

Core

Header

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

Include

#include "Templates/SharedPointer.h"

Syntax

template<class ObjectType, ESPMode InMode>
class TWeakPtr

Remarks

TWeakPtr is a non-intrusive reference-counted weak object pointer. This weak pointer will be conditionally thread-safe when the optional Mode template argument is set to ThreadSafe.

Constructors

Name Description

Public function

TWeakPtr

NOTE: FNullTag parameter is an Unreal extension to standard shared_ptr behavior.

Public function

TWeakPtr

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

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

Public function

TWeakPtr

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

Constructs a weak pointer from a shared pointer

Public function

TWeakPtr

(
    TWeakPtr< OtherType, Mode > const&...
)

Constructs a weak pointer from a weak pointer of another type.

Public function

TWeakPtr

(
    TWeakPtr< OtherType, Mode >&& InWe...
)

Public function

TWeakPtr

(
    TWeakPtr const& InWeakPtr
)

Public function

TWeakPtr

(
    TWeakPtr&& InWeakPtr
)

Public function

TWeakPtr

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

Special constructor used internally to statically cast one weak pointer type to another.

Public function

TWeakPtr

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

Special constructor used internally to cast a 'const' weak pointer a 'mutable' pointer.

Functions

Name Description

Public function Const

uint32

 

GetWeakPtrTypeHash()

Public function Const

bool

 

HasSameObject

(
    const void* InOtherPtr
)

Returns true if the object this weak pointer points to is the same as the specified object pointer.

Public function Const

bool

 

IsValid()

Checks to see if this weak pointer actually has a valid reference to an object

Public function Const

TSharedPtr< ...

 

Pin()

Converts this weak pointer to a shared pointer that you can use to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the returned shared pointer will not be valid.

Public function

TSharedPtr< ...

 

Pin()

Converts this weak pointer to a shared pointer that you can use to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the returned shared pointer will not be valid.

Public function

void

 

Reset()

Resets this weak pointer, removing a weak reference to the object.

Operators

Name Description

Public function

TWeakPtr &

 

operator=

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

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

Public function

TWeakPtr &

 

operator=

(
    TWeakPtr< OtherType, Mode >&& InWe...
)

Public function

TWeakPtr &

 

operator=

(
    TWeakPtr< OtherType, Mode > const&...
)

Assignment operator adds a weak reference to the object referenced by the specified weak pointer.

Public function

TWeakPtr &

 

operator=

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

Assignment operator sets this weak pointer from a shared pointer

Public function

TWeakPtr &

 

operator=

(
    TWeakPtr const& InWeakPtr
)

Assignment operator adds a weak reference to the object referenced by the specified weak pointer

Public function

TWeakPtr &

 

operator=

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

Public function

TWeakPtr &

 

operator=

(
    TWeakPtr&& InWeakPtr
)

Typedefs

Name

Description

ElementType

Constants

Name

Description

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