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!

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback