UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TWeakInterfacePtr< T > Struct Template Reference

#include <WeakInterfacePtr.h>

Public Types

using ElementType = T
 
using UObjectType = TCopyQualifiersFromTo_T< T, UObject >
 

Public Member Functions

UE_FORCEINLINE_HINT TWeakInterfacePtr ()=default
 
UE_FORCEINLINE_HINT TWeakInterfacePtr (const TWeakInterfacePtr &Other)=default
 
UE_FORCEINLINE_HINT TWeakInterfacePtr (TWeakInterfacePtr &&Other)=default
 
UE_FORCEINLINE_HINT ~TWeakInterfacePtr ()=default
 
UE_FORCEINLINE_HINT TWeakInterfacePtroperator= (const TWeakInterfacePtr &Other)=default
 
UE_FORCEINLINE_HINT TWeakInterfacePtroperator= (TWeakInterfacePtr &&Other)=default
 
UE_FORCEINLINE_HINT TWeakInterfacePtr (TYPE_OF_NULLPTR)
 
template<typename U >
 TWeakInterfacePtr (U &&Object)
 
 TWeakInterfacePtr (T *Interface)
 
 TWeakInterfacePtr (const TScriptInterface< T > &ScriptInterface)
 
void Reset ()
 
UE_FORCEINLINE_HINT bool IsValid (bool bEvenIfPendingKill, bool bThreadsafeTest=false) const
 
UE_FORCEINLINE_HINT bool IsValid () const
 
UE_FORCEINLINE_HINT bool IsStale (bool bEvenIfPendingKill=false, bool bThreadsafeTest=false) const
 
UE_FORCEINLINE_HINT T * Get () const
 
UE_FORCEINLINE_HINT UObjectTypeGetObject () const
 
T & operator* () const
 
T * operator-> () const
 
TWeakInterfacePtr< T > & operator= (T *Other)
 
TWeakInterfacePtr< T > & operator= (const TScriptInterface< T > &Other)
 
UE_FORCEINLINE_HINT bool operator== (const TWeakInterfacePtr< T > &Other) const
 
UE_FORCEINLINE_HINT bool operator!= (const TWeakInterfacePtr< T > &Other) const
 
FORCENOINLINE bool operator== (TYPE_OF_NULLPTR) const
 
UE_FORCEINLINE_HINT bool operator!= (TYPE_OF_NULLPTR) const
 
TScriptInterface< T > ToScriptInterface () const
 
UE_FORCEINLINE_HINT TWeakObjectPtr< UObjectTypeGetWeakObjectPtr () const
 

Detailed Description

template<class T>
struct TWeakInterfacePtr< T >

An alternative to TWeakObjectPtr that makes it easier to work through an interface.

Member Typedef Documentation

◆ ElementType

template<class T >
using TWeakInterfacePtr< T >::ElementType = T

◆ UObjectType

template<class T >
using TWeakInterfacePtr< T >::UObjectType = TCopyQualifiersFromTo_T<T, UObject>

Constructor & Destructor Documentation

◆ TWeakInterfacePtr() [1/7]

template<class T >
UE_FORCEINLINE_HINT TWeakInterfacePtr< T >::TWeakInterfacePtr ( )
default

◆ TWeakInterfacePtr() [2/7]

template<class T >
UE_FORCEINLINE_HINT TWeakInterfacePtr< T >::TWeakInterfacePtr ( const TWeakInterfacePtr< T > &  Other)
default

◆ TWeakInterfacePtr() [3/7]

template<class T >
UE_FORCEINLINE_HINT TWeakInterfacePtr< T >::TWeakInterfacePtr ( TWeakInterfacePtr< T > &&  Other)
default

◆ ~TWeakInterfacePtr()

template<class T >
UE_FORCEINLINE_HINT TWeakInterfacePtr< T >::~TWeakInterfacePtr ( )
default

◆ TWeakInterfacePtr() [4/7]

Construct from a null pointer

◆ TWeakInterfacePtr() [5/7]

template<class T >
template<typename U >
TWeakInterfacePtr< T >::TWeakInterfacePtr ( U &&  Object)
inline

Construct from an object pointer

Parameters
ObjectThe object to create a weak pointer to. This object must implement interface T.

◆ TWeakInterfacePtr() [6/7]

template<class T >
TWeakInterfacePtr< T >::TWeakInterfacePtr ( T *  Interface)
inline

Construct from an interface pointer

Parameters
InterfaceThe interface pointer to create a weak pointer to. There must be a UObject behind the interface.

◆ TWeakInterfacePtr() [7/7]

template<class T >
TWeakInterfacePtr< T >::TWeakInterfacePtr ( const TScriptInterface< T > &  ScriptInterface)
inline

Construct from a TScriptInterface of the same interface type

Parameters
ScriptInterfaceThe TScriptInterface to copy from. No validation is done here; passing an invalid TScriptInterface in will result in an invalid TWeakInterfacePtr.

Member Function Documentation

◆ Get()

template<class T >
UE_FORCEINLINE_HINT T * TWeakInterfacePtr< T >::Get ( ) const
inline

Dereference the weak pointer into an interface pointer.

◆ GetObject()

template<class T >
UE_FORCEINLINE_HINT UObjectType * TWeakInterfacePtr< T >::GetObject ( ) const
inline

Dereference the weak pointer into a UObject pointer.

◆ GetWeakObjectPtr()

template<class T >
UE_FORCEINLINE_HINT TWeakObjectPtr< UObjectType > TWeakInterfacePtr< T >::GetWeakObjectPtr ( ) const
inline

◆ IsStale()

template<class T >
UE_FORCEINLINE_HINT bool TWeakInterfacePtr< T >::IsStale ( bool  bEvenIfPendingKill = false,
bool  bThreadsafeTest = false 
) const
inline

Test if this pointer is stale. Parameters are passed to the underlying TWeakObjectPtr.

◆ IsValid() [1/2]

template<class T >
UE_FORCEINLINE_HINT bool TWeakInterfacePtr< T >::IsValid ( ) const
inline

Test if this points to a live object. Calls the underlying TWeakObjectPtr's parameterless IsValid method.

◆ IsValid() [2/2]

template<class T >
UE_FORCEINLINE_HINT bool TWeakInterfacePtr< T >::IsValid ( bool  bEvenIfPendingKill,
bool  bThreadsafeTest = false 
) const
inline

Test if this points to a live object. Parameters are passed to the underlying TWeakObjectPtr.

◆ operator!=() [1/2]

template<class T >
UE_FORCEINLINE_HINT bool TWeakInterfacePtr< T >::operator!= ( const TWeakInterfacePtr< T > &  Other) const
inline

◆ operator!=() [2/2]

template<class T >
UE_FORCEINLINE_HINT bool TWeakInterfacePtr< T >::operator!= ( TYPE_OF_NULLPTR  ) const
inline

◆ operator*()

template<class T >
T & TWeakInterfacePtr< T >::operator* ( ) const
inline

Dereference the weak pointer.

◆ operator->()

template<class T >
T * TWeakInterfacePtr< T >::operator-> ( ) const
inline

Dereference the weak pointer.

◆ operator=() [1/4]

template<class T >
TWeakInterfacePtr< T > & TWeakInterfacePtr< T >::operator= ( const TScriptInterface< T > &  Other)
inline

Assign from a script interface.

◆ operator=() [2/4]

template<class T >
UE_FORCEINLINE_HINT TWeakInterfacePtr & TWeakInterfacePtr< T >::operator= ( const TWeakInterfacePtr< T > &  Other)
default

◆ operator=() [3/4]

template<class T >
TWeakInterfacePtr< T > & TWeakInterfacePtr< T >::operator= ( T *  Other)
inline

Assign from an interface pointer.

◆ operator=() [4/4]

template<class T >
UE_FORCEINLINE_HINT TWeakInterfacePtr & TWeakInterfacePtr< T >::operator= ( TWeakInterfacePtr< T > &&  Other)
default

◆ operator==() [1/2]

template<class T >
UE_FORCEINLINE_HINT bool TWeakInterfacePtr< T >::operator== ( const TWeakInterfacePtr< T > &  Other) const
inline

◆ operator==() [2/2]

template<class T >
FORCENOINLINE bool TWeakInterfacePtr< T >::operator== ( TYPE_OF_NULLPTR  ) const
inline

◆ Reset()

template<class T >
void TWeakInterfacePtr< T >::Reset ( )
inline

Reset the weak pointer back to the null state.

◆ ToScriptInterface()

template<class T >
TScriptInterface< T > TWeakInterfacePtr< T >::ToScriptInterface ( ) const
inline

The documentation for this struct was generated from the following file: