RealDocs

TSharedPtr::Object

property Core Since 4.0
#include "Templates/SharedPointer.h"
Access: private

Description

The raw pointer to the managed object. Null when the shared pointer is empty. Access the managed object through Get(), operator*(), or operator->() rather than this field.

Caveats & Gotchas

  • Object is a private member. External code cannot access it directly; use Get() to retrieve the raw pointer. Friendship is granted to TSharedRef, TWeakPtr, and TSharedFromThis for internal operations only.
  • Object can be null for an empty TSharedPtr — unlike TSharedRef, which enforces non-null via constructor checks. Always test IsValid() or operator bool() before dereferencing through the public API.
  • When a TSharedPtr is move-constructed from another, the source's Object is set to nullptr. This is how the shared pointer signals it no longer owns a reference.

Signature

ObjectType* Object

Example

Accessing the raw pointer through the public API C++
TSharedPtr<FMyData> DataPtr = MakeShared<FMyData>();

// Correct: use Get() for the raw pointer
FMyData* Raw = DataPtr.Get();

// DataPtr.Object is private — this won't compile:
// FMyData* Raw2 = DataPtr.Object;

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.