class

TObjectPtr

UE's TObjectPtr: behaves like a plain T* in every read, but every STORE shades the new referent through the incremental GC's write barrier — a mid-mark assignment can no longer hide a white object behind an already-black owner. It does NOT root; reachability comes from the owner's MPROPERTY trace, exactly like a raw pointer. A traced one whose target is destroyed (pending kill) is nulled by the next mark, before the sweep frees the target; an untraced one (a local, a member that is not an MPROPERTY) is not, which is what TWeakObjectPtr is for.

Module
Core
Header
#include "Core/TObjectPtr.h"
Namespace
Mowo
Template
template<typename T>

The incremental GC (mowo.GC.Incremental) is only sound over object graphs whose MPROPERTY edges are barriered — migrate a class's raw MPROPERTY pointers to TObjectPtr before budget-marking worlds built from it. Codegen needs no changes: the CollectReference overload set traces it, and sizeof(TObjectPtr<T>) == sizeof(T*).

Constructors

SignatureNameDescription
constexpr TObjectPtr() = defaultTObjectPtr
TObjectPtr(T* ptr)TObjectPtr
TObjectPtr(const TObjectPtr& other)TObjectPtr

Public functions

ReturnsNameDescription
TObjectPtr&operator=
TObjectPtr&operator=
T*Get
T*operator->
T&operator*
operatorT*
operatorbool
voidClearGarbageReferenceThe GC's own write, during a mark: drops a reference whose target is pending kill (destroyed, or purged by its module's unload), so nothing points at it once the sweep frees it.

Function details

TObjectPtr

C++
constexpr TObjectPtr() = default

TObjectPtr

C++
TObjectPtr(T* ptr)

TObjectPtr

C++
TObjectPtr(const TObjectPtr& other)

operator=

C++
TObjectPtr& operator=(T* ptr)

operator=

C++
TObjectPtr& operator=(const TObjectPtr& other)

Get

C++
T* Get() const noexcept

operator->

C++
T* operator->() const noexcept

operator*

C++
T& operator*() const noexcept

operatorT*

C++
operator T*() const noexcept

operatorbool

C++
explicit operator bool() const noexcept

ClearGarbageReference

C++
void ClearGarbageReference() noexcept

The GC's own write, during a mark: drops a reference whose target is pending kill (destroyed, or purged by its module's unload), so nothing points at it once the sweep frees it. Unbarriered on purpose — it stores null.

Generated from Core/TObjectPtr.h via core.json · Nov 5, 2026Version 1.0.0