TWeakPtr

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

Choose your operating system:

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

Constructs an empty TWeakPtr

Public function

TWeakPtr

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

Constructs a weak pointer from a shared reference

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
)

Functions

Name Description

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

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

Assignment operator sets this weak pointer from a shared reference

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=

Assignment to a nullptr pointer. Clears this weak pointer's reference.

Public function

TWeakPtr &

 

operator=

(
    TWeakPtr&& InWeakPtr
)

Typedefs

Name

Description

ElementType

Constants

Name

Description

Mode