class

WeakRef

WeakRef<T> — non-owning reference to a RefCounted object. Does not keep the object alive; Lock() promotes to a Ref when it is still there.

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

The observation lives in the object's FWeakRefControl, which outlives the object, so every operation here is safe after the last strong ref is gone.

Type aliases

AliasDescription
using element_type = T

Constructors

SignatureNameDescription
constexpr WeakRef() noexcept : m_ptr(nullptr), m_control(nullptr)WeakRef
constexpr WeakRef(std::nullptr_t) noexcept : m_ptr(nullptr), m_control(nullptr)WeakRef
WeakRef(const Ref<T>& ref) noexcept : m_ptr(ref.Get()), m_control(nullptr)WeakRef
WeakRef(const WeakRef& other) noexcept : m_ptr(other.m_ptr), m_control(other.m_c…WeakRef
WeakRef(WeakRef&& other) noexcept : m_ptr(other.m_ptr), m_control(other.m_contro…WeakRef
template<typename U> WeakRef(const WeakRef<U>& other) noexcept : m_ptr(other.m_p…WeakRef
template<typename U> WeakRef(WeakRef<U>&& other) noexcept : m_ptr(other.m_ptr), …WeakRef
~WeakRef()~WeakRef

Public functions

ReturnsNameDescription
WeakRef&operator=
WeakRef&operator=
WeakRef&operator=
Ref<T>LockPromote to a strong Ref; null Ref if the object has been destroyed.
boolIsValidA true answer is only a snapshot — use Lock() when you intend to touch the object.
boolIsNull
operatorbool
voidReset
T*GetUnsafeMay be dangling — only for identity comparisons, never to dereference.
booloperator==
booloperator!=
booloperator==
booloperator!=

Function details

WeakRef

C++
constexpr WeakRef() noexcept : m_ptr(nullptr), m_control(nullptr)

WeakRef

C++
constexpr WeakRef(std::nullptr_t) noexcept : m_ptr(nullptr), m_control(nullptr)

WeakRef

C++
WeakRef(const Ref<T>& ref) noexcept : m_ptr(ref.Get()), m_control(nullptr)

WeakRef

C++
WeakRef(const WeakRef& other) noexcept : m_ptr(other.m_ptr), m_control(other.m_control)

WeakRef

C++
WeakRef(WeakRef&& other) noexcept : m_ptr(other.m_ptr), m_control(other.m_control)

WeakRef

C++
template<typename U> WeakRef(const WeakRef<U>& other) noexcept : m_ptr(other.m_ptr), m_control(other.m_control)

WeakRef

C++
template<typename U> WeakRef(WeakRef<U>&& other) noexcept : m_ptr(other.m_ptr), m_control(other.m_control)

~WeakRef

C++
~WeakRef()

operator=

C++
WeakRef& operator=(const WeakRef& other) noexcept

operator=

C++
WeakRef& operator=(WeakRef&& other) noexcept

operator=

C++
WeakRef& operator=(std::nullptr_t) noexcept

Lock

C++
Ref<T> Lock() const noexcept

Promote to a strong Ref; null Ref if the object has been destroyed. The lock excludes ~RefCounted, and TryIncRef refuses a zero count, so the returned Ref can never name an object that is already dying.

IsValid

C++
bool IsValid() const noexcept

A true answer is only a snapshot — use Lock() when you intend to touch the object.

IsNull

C++
bool IsNull() const noexcept

operatorbool

C++
explicit operator bool() const noexcept

Reset

C++
void Reset() noexcept

GetUnsafe

C++
T* GetUnsafe() const noexcept

May be dangling — only for identity comparisons, never to dereference.

operator==

C++
bool operator==(const WeakRef& other) const noexcept

operator!=

C++
bool operator!=(const WeakRef& other) const noexcept

operator==

C++
bool operator==(std::nullptr_t) const noexcept

operator!=

C++
bool operator!=(std::nullptr_t) const noexcept
Generated from Core/WeakRef.h via core.json · Nov 5, 2026Version 1.0.0