3#include <fsdk/Types/Ref.h>
4#include <fsdk/Types/RefBase.h>
7#ifndef DOXYGEN_SHOULD_SKIP_THIS
17 struct WeakRef : RefBase<T> {
21 WeakRef() noexcept = default;
25 WeakRef(std::nullptr_t) noexcept {
31 explicit WeakRef(T* ptr)
noexcept {
38 WeakRef(
const WeakRef& other)
noexcept {
45 WeakRef(
const Ref<T>& other)
noexcept {
59 WeakRef& operator=(
const Ref<T>& other)
noexcept {
60 return assign(other.get());
67 WeakRef& operator=(
const WeakRef& other)
noexcept {
68 return assign(other.get());
76 WeakRef& operator=(T* ptr)
noexcept {
84 WeakRef& operator=(std::nullptr_t)
noexcept {
93 WeakRef& assign(T* ptr)
noexcept {
94 if(this->get() != ptr) {
96 this->get()->releaseWeak();
101 this->get()->retainWeak();
110 void reset() noexcept {
118 Ref<T> lock() const noexcept {
119 return (!this->get() || this->isExpired()) ? Ref<T>() : Ref<T>(*this);
125 template <
typename S>
126 WeakRef<S> as() noexcept {
127 return WeakRef<S>(
static_cast<S*
>(this->get()));
135 template <
typename T>
136 inline WeakRef<T> make_weak_ref(T* ptr)
noexcept {
137 return WeakRef<T>(ptr);
145 template <
typename S,
typename T>
146 inline WeakRef<S> make_weak_ref_as(T* ptr)
noexcept {
147 return WeakRef<S>(
static_cast<S*
>(ptr));
151 template <
typename T>
153 if(this->get() != other.get()) {
155 this->get()->release();
157 this->set(other.get());
160 if(this->get() && this->get()->retainLocked() < 1)
SDK namespace.
Definition IAGSEstimator.h:8
Ref & operator=(const Ref &other) noexcept
Assign a strong reference.
Definition Ref.h:136