RealDocs

TSharedRef::Object

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

Description

The raw pointer to the managed object. Always non-null in a valid TSharedRef — guaranteed by constructor checks. Access through Get() or operator*() rather than directly.

Caveats & Gotchas

  • Object is private. There is no public raw-pointer accessor named Get() that returns by value on TSharedRef; instead Get() returns a reference (ObjectType&). Use Get() or ToSharedPtr().Get() for a raw pointer.
  • The only scenario where Object can be null internally is the special FIntrusiveUnsetOptionalState constructor, which creates an unset sentinel for TOptional<TSharedRef> support. User code never creates TSharedRef in this state directly.
  • Friendship grants access to TSharedPtr, TWeakPtr, and the MakeSharedRef factory — not to arbitrary user code.

Signature

ObjectType* Object

Example

Accessing the object through the public interface C++
TSharedRef<FMyData> DataRef = MakeShared<FMyData>();

// Get() returns a reference, not a pointer:
FMyData& DataByRef = DataRef.Get();

// For a raw pointer, convert to TSharedPtr first:
FMyData* RawPtr = DataRef.ToSharedPtr().Get();

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.