ludus::foundation::SharedPtr¶
Ludus Wiki · API overview · Browse API
Class
TryMakeShared. WeakPtr observers. An upcast changes only the view.Reset that adopts a raw pointer: the only source of ownership is TryMakeShared (or WeakPtr::Lock of an object it created). Never create a second owner from Get() or this.| Template parameter | Description |
|---|---|
ElementType |
Owned object type, optionally cv-qualified. Arrays, references, functions and
void are rejected. It may be incomplete where an owner is declared, copied or destroyed: destruction runs through the creator's type-erased thunk. |
Note
SharedPtr value need external synchronization. Ownership does not synchronize access to the object; prefer immutable SharedPtr<const T> snapshots. Note
SharedPtr. 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::SharedPtr
Members¶
detail::SharedOwnerAccess¶
friend struct detail::SharedOwnerAccess
TryMakeShared adopt the hold of a newly created controller; not caller API. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator==¶
LUDUS_INLINE bool operator==(const SharedPtr &owner, nullptr_t) noexcept
owner is empty (also provides !=, and either operand order). Related types: nullptr_t
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
Methods¶
SharedPtr¶
constexpr ludus::foundation::SharedPtr< ElementType >::SharedPtr() noexcept=default
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
SharedPtr¶
constexpr ludus::foundation::SharedPtr< ElementType >::SharedPtr(nullptr_t) noexcept
Related types: nullptr_t
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
SharedPtr¶
ludus::foundation::SharedPtr< ElementType >::SharedPtr(const SharedPtr &other) noexcept
other's object, adding one strong owner. | Parameter | Description |
|---|---|
other |
Owner to copy; may be empty.
|
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
SharedPtr¶
template <typename OtherElementType>
ludus::foundation::SharedPtr< ElementType >::SharedPtr(const SharedPtr< OtherElementType > &other) noexcept
requires detail::SharedViewConversion<OtherElementType, ElementType>
other's object through an upcast or cv-qualified view. other keeps the object alive; destruction remains that of the created type. | Parameter | Description |
|---|---|
other |
Owner to copy; may be empty.
|
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
SharedPtr¶
ludus::foundation::SharedPtr< ElementType >::SharedPtr(SharedPtr &&other) noexcept
other's ownership without reference traffic, leaving other empty. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
SharedPtr¶
template <typename OtherElementType>
ludus::foundation::SharedPtr< ElementType >::SharedPtr(SharedPtr< OtherElementType > &&other) noexcept
requires detail::SharedViewConversion<OtherElementType, ElementType>
other's ownership through an upcast or cv-qualified view, leaving other empty. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
~SharedPtr¶
ludus::foundation::SharedPtr< ElementType >::~SharedPtr()
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
SharedPtr & ludus::foundation::SharedPtr< ElementType >::operator=(const SharedPtr &other) noexcept
other's object, then releases the previous one. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
template <typename OtherElementType>
SharedPtr & ludus::foundation::SharedPtr< ElementType >::operator=(const SharedPtr< OtherElementType > &other) noexcept
requires detail::SharedViewConversion<OtherElementType, ElementType>
other's object through a converted view, then releases the previous one. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
SharedPtr & ludus::foundation::SharedPtr< ElementType >::operator=(SharedPtr &&other) noexcept
other's ownership, then releases the previous one. other emptied before the previous hold is released, so head = Move(head->Next) is valid. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
template <typename OtherElementType>
SharedPtr & ludus::foundation::SharedPtr< ElementType >::operator=(SharedPtr< OtherElementType > &&other) noexcept
requires detail::SharedViewConversion<OtherElementType, ElementType>
other's ownership through a converted view, then releases the previous one. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator=¶
SharedPtr & ludus::foundation::SharedPtr< 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::SharedPtr< ElementType >::Reset() noexcept
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
Swap¶
void ludus::foundation::SharedPtr< ElementType >::Swap(SharedPtr &inoutOther) noexcept
other without reference traffic. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
Get¶
LUDUS_INLINE ElementType * ludus::foundation::SharedPtr< ElementType >::Get() const noexcept
Returns
nullptr for an empty owner. Valid only while some strong owner keeps the object alive. Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator*¶
LUDUS_INLINE ElementType & ludus::foundation::SharedPtr< ElementType >::operator*() const noexcept
Precondition
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator->¶
LUDUS_INLINE ElementType * ludus::foundation::SharedPtr< ElementType >::operator->() const noexcept
Precondition
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp
operator bool¶
explicit LUDUS_INLINE ludus::foundation::SharedPtr< ElementType >::operator bool() const noexcept
Declared in modules/foundation/memory/include/ludus/foundation/memory/shared_ptr.hpp