TSharedPtr::TSharedPtr

Constructs a shared pointer from a weak pointer, allowing you to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the shared pointer will not be valid.

Windows
MacOS
Linux

References

Module

Core

Header

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

Include

#include "Templates/SharedPointer.h"

Syntax

template<typename OtherType, typename>
TSharedPtr
(
    TWeakPtr< OtherType, Mode > && InWeakPtr
)

Remarks

Constructs a shared pointer from a weak pointer, allowing you to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the shared pointer will not be valid. You should always check to make sure this shared pointer is valid before trying to dereference the shared pointer!

NOTE: This constructor is private to force users to be explicit when converting a weak pointer to a shared pointer. Use the weak pointer's Pin() method instead!

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