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
| Alias | Description |
|---|---|
using element_type = T |
Constructors
| Signature | Name | Description |
|---|---|---|
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
| Returns | Name | Description |
|---|---|---|
WeakRef& | operator= | |
WeakRef& | operator= | |
WeakRef& | operator= | |
Ref<T> | Lock | Promote to a strong Ref; null Ref if the object has been destroyed. |
bool | IsValid | A true answer is only a snapshot — use Lock() when you intend to touch the object. |
bool | IsNull | |
operatorbool | ||
void | Reset | |
T* | GetUnsafe | May be dangling — only for identity comparisons, never to dereference. |
bool | operator== | |
bool | operator!= | |
bool | operator== | |
bool | operator!= |
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) noexceptoperator=
C++
WeakRef& operator=(WeakRef&& other) noexceptoperator=
C++
WeakRef& operator=(std::nullptr_t) noexceptLock
C++
Ref<T> Lock() const noexceptPromote 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 noexceptA true answer is only a snapshot — use Lock() when you intend to touch the object.
IsNull
C++
bool IsNull() const noexceptoperatorbool
C++
explicit operator bool() const noexceptReset
C++
void Reset() noexceptGetUnsafe
C++
T* GetUnsafe() const noexceptMay be dangling — only for identity comparisons, never to dereference.
operator==
C++
bool operator==(const WeakRef& other) const noexceptoperator!=
C++
bool operator!=(const WeakRef& other) const noexceptoperator==
C++
bool operator==(std::nullptr_t) const noexceptoperator!=
C++
bool operator!=(std::nullptr_t) const noexceptGenerated from Core/WeakRef.h via core.json · Nov 5, 2026Version 1.0.0