TWeakObjectPtr

[TWeakObjectPtr](API\Runtime\Core\UObject\TWeakObjectPtr) is the templated version of the generic [FWeakObjectPtr](API\Runtime\CoreUObject\UObject\FWeakObjectPtr)

Inheritance Hierarchy

TWeakObjectPtrBase

TWeakObjectPtr

TAutoWeakObjectPtr

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/UObject/WeakObjectPtrTemplates.h

Include

#include "UObject/WeakObjectPtrTemplates.h"

Syntax

template<class T, class TWeakObjectPtrBase>
struct TWeakObjectPtr : private TWeakObjectPtrBase

Remarks

TWeakObjectPtr is the templated version of the generic FWeakObjectPtr

Constructors

Name Description

Public function

TWeakObjectPtr()

Public function

TWeakObjectPtr

(
    const TWeakObjectPtr&
)

Public function

TWeakObjectPtr

(
    TYPE_OF_NULLPTR
)

Construct from a null pointer

Public function

TWeakObjectPtr

(
    U Object
)

Construct from an object pointer

Public function

TWeakObjectPtr

(
    const TWeakObjectPtr< OtherT, TWeak...
)

Construct from another weak pointer of another type, intended for derived-to-base conversions

Destructors

Name Description

Public function

~TWeakObjectPtr()

Functions

Name Description

Public function Const

T *

 

Get

(
    bool bEvenIfPendingKill
)

Dereference the weak pointer

Public function Const

T *

 

Get()

Dereference the weak pointer. This is an optimized version implying bEvenIfPendingKill=false.

Public function Const

T *

 

GetEvenIfUnreachable()

Deferences the weak pointer even if its marked RF_Unreachable.

Public function Const

uint32

 

GetWeakPtrTypeHash()

Hash function.

Public function Const

bool

 

HasSameIndexAndSerialNumber

(
    const TWeakObjectPtr& Other
)

Returns true if two weak pointers were originally set to the same object, even if they are now stale

Public function Const

bool

 

IsExplicitlyNull()

Returns true if this pointer was explicitly assigned to null, was reset, or was never initialized.

Public function Const

bool

 

IsStale

(
    bool bIncludingIfPendingKill,
    bool bThreadsafeTest
)

Slightly different than !IsValid(), returns true if this used to point to a UObject, but doesn't any more and has not been assigned or reset in the mean time.

Public function Const

bool

 

IsValid()

Test if this points to a live UObject.

Public function Const

bool

 

IsValid

(
    bool bEvenIfPendingKill,
    bool bThreadsafeTest
)

Test if this points to a live UObject.

Public function

void

 

Reset()

Reset the weak pointer back to the null state

Public function

void

 

Serialize

(
    FArchive& Ar
)

Weak object pointer serialization, this forwards to FArchive::operator<<(struct FWeakObjectPtr&) or an override

Operators

Name Description

Public function Const

 

operator bool()

This is explicitly not added to avoid resolving weak pointers too often - use Get() once in a function.

Public function Const

bool

 

operator!=

(
    const TWeakObjectPtr< RhsT, TWeakOb...
)

Compare weak pointers for inequality

Public function Const

bool

 

operator!=

(
    const RhsT* Rhs
)

Public function Const

bool

 

operator!=

(
    TYPE_OF_NULLPTR
)

Public function Const

T &

 

operator*()

Dereference the weak pointer

Public function

TEnableIf<&#...

 

operator=

(
    U* Object
)

Copy from an object pointer

Public function

TWeakObjectP...

 

operator=

(
    const TWeakObjectPtr&
)

Public function

TWeakObjectP...

 

operator=

(
    const TWeakObjectPtr< OtherT, TWeak...
)

Assign from another weak pointer, intended for derived-to-base conversions

Public function Const

bool

 

operator==

(
    TYPE_OF_NULLPTR
)

Public function Const

bool

 

operator==

(
    const TWeakObjectPtr< RhsT, TWeakOb...
)

Compare weak pointers for equality.

Public function Const

bool

 

operator==

(
    const RhsT* Rhs
)

Public function Const

T *

 

operator->()

Dereference the weak pointer

Typedefs

Name

Description

ElementType

Although templated, these parameters are not intended to be anything other than the default, and are only templates for module organization reasons.

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