ludus::foundation::WeakPtr¶
Ludus Wiki · API overview · Browse API
Class
SharedPtr. Lock() obtains a temporary strong owner while the object is live and returns empty forever after the final strong release; a weak value never follows a replacement object. There is deliberately no Get, dereference or arrow operator: access the object only through Lock().| Template parameter | Description |
|---|---|
ElementType |
Observed object type, optionally cv-qualified. Arrays, references, functions and
void are rejected. |
Note
SharedPtr, distinct values may be used concurrently; one variable needs external synchronization. Note
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
#include <ludus/foundation/memory/shared_ptr.hpp>
template <typename ElementType>
class ludus::foundation::WeakPtr
Methods¶
WeakPtr¶
constexpr ludus::foundation::WeakPtr< ElementType >::WeakPtr() noexcept=default
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
WeakPtr¶
constexpr ludus::foundation::WeakPtr< ElementType >::WeakPtr(nullptr_t) noexcept
Related types: nullptr_t
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
WeakPtr¶
template <typename OtherElementType>
ludus::foundation::WeakPtr< ElementType >::WeakPtr(const SharedPtr< OtherElementType > &owner) noexcept
requires std::is_convertible_v<OtherElementType*, ElementType*>
owner's object, possibly through an upcast or cv-qualified view. owner keeps the object alive. | Parameter | Description |
|---|---|
owner |
Strong owner to observe; an empty owner yields an empty observer.
|
Related types: SharedPtr
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
WeakPtr¶
ludus::foundation::WeakPtr< ElementType >::WeakPtr(const WeakPtr &other) noexcept
other. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
WeakPtr¶
template <typename OtherElementType>
ludus::foundation::WeakPtr< ElementType >::WeakPtr(const WeakPtr< OtherElementType > &other) noexcept
requires detail::WeakViewConversion<OtherElementType, ElementType>
other through a more cv-qualified view. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
WeakPtr¶
ludus::foundation::WeakPtr< ElementType >::WeakPtr(WeakPtr &&other) noexcept
other's observation without reference traffic, leaving other empty. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
WeakPtr¶
template <typename OtherElementType>
ludus::foundation::WeakPtr< ElementType >::WeakPtr(WeakPtr< OtherElementType > &&other) noexcept
requires detail::WeakViewConversion<OtherElementType, ElementType>
other's observation through a more cv-qualified view, leaving other empty. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
~WeakPtr¶
ludus::foundation::WeakPtr< ElementType >::~WeakPtr()
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
WeakPtr & ludus::foundation::WeakPtr< ElementType >::operator=(const WeakPtr &other) noexcept
other's object, then releases the previous weak hold. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
template <typename OtherElementType>
WeakPtr & ludus::foundation::WeakPtr< ElementType >::operator=(const SharedPtr< OtherElementType > &owner) noexcept
requires std::is_convertible_v<OtherElementType*, ElementType*>
owner's object, then releases the previous weak hold. | Parameter | Description |
|---|---|
owner |
Strong owner to observe; an empty owner empties this observer.
|
Related types: SharedPtr
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
WeakPtr & ludus::foundation::WeakPtr< ElementType >::operator=(WeakPtr &&other) noexcept
other's observation, then releases the previous weak hold. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
WeakPtr & ludus::foundation::WeakPtr< ElementType >::operator=(nullptr_t) noexcept
Related types: nullptr_t
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
Reset¶
void ludus::foundation::WeakPtr< ElementType >::Reset() noexcept
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
Swap¶
void ludus::foundation::WeakPtr< ElementType >::Swap(WeakPtr &inoutOther) noexcept
other without reference traffic. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
IsExpired¶
bool ludus::foundation::WeakPtr< ElementType >::IsExpired() const noexcept
true is permanent. false can become stale immediately on another thread: never check and then access; use the owner returned by Lock(). Returns
true for an empty observer or once the final strong release committed. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
Lock¶
SharedPtr< ElementType > ludus::foundation::WeakPtr< ElementType >::Lock() const noexcept
Returns
Related types: SharedPtr
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp