ludus::foundation::core::UniquePtr¶
Ludus Wiki · API overview · Browse API
Class
noexcept. An empty owner never invokes its deleter.sizeof(UniquePtr<T>) == sizeof(T*).| Template parameter | Description |
|---|---|
ElementType |
Owned object type. May be incomplete where the owner is declared (PIMPL); it must be complete wherever the default deleter is instantiated. Array types are rejected; use a Ludus container for sequences and byte buffers.
|
DeleterType |
Value deleter satisfying
Deleter<DeleterType, ElementType>. |
Note
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
#include <ludus/foundation/base/pointer.hpp>
template <typename ElementType, Deleter< ElementType > DeleterType = DefaultDeleter<ElementType>>
class ludus::foundation::core::UniquePtr final
Methods¶
UniquePtr¶
constexpr ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr() noexcept
requires std::is_nothrow_default_constructible_v<DeleterType>
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
constexpr ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(nullptr_t) noexcept
requires std::is_nothrow_default_constructible_v<DeleterType>
Related types: nullptr_t
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
explicit ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(ElementType *&inoutPointer) noexcept
requires std::is_nothrow_default_constructible_v<DeleterType>
inoutPointer with a value-initialized deleter and nulls the source. | Parameter | Description |
|---|---|
inoutPointer |
Uniquely owned object created for this deleter's protocol, or
nullptr. Set to nullptr on return. |
Precondition
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(ElementType *&inoutPointer, DeleterType deleter) noexcept
requires std::is_nothrow_move_constructible_v<DeleterType>
inoutPointer together with the deleter that must destroy it. | Parameter | Description |
|---|---|
inoutPointer |
Uniquely owned object matching
deleter's protocol, or nullptr. Set to nullptr on return. |
deleter |
Destruction protocol, moved into the owner.
|
Precondition
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(const UniquePtr &)=delete
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(UniquePtr &&other) noexcept
requires std::is_nothrow_move_constructible_v<DeleterType>
other, leaving other empty. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
template <typename OtherElementType, typename OtherDeleterType>
ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(UniquePtr< OtherElementType, OtherDeleterType > &&other) noexcept
requires detail::ImplicitOwnerConversion<OtherElementType, OtherDeleterType, ElementType, DeleterType> && std::is_nothrow_default_constructible_v<DeleterType>
delete owner of a derived object (or a less cv-qualified object) into an owner of ElementType. DefaultDeleter owners when the pointer conversion is accessible and unambiguous and either the object types differ only in cv-qualification or ElementType has a virtual destructor. other is left empty. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
UniquePtr¶
template <typename OtherElementType, typename OtherDeleterType>
explicit ludus::foundation::core::UniquePtr< ElementType, DeleterType >::UniquePtr(UniquePtr< OtherElementType, OtherDeleterType > &&other) noexcept
requires detail::AdaptedOwnerConversion<OtherElementType, OtherDeleterType, ElementType, DeleterType>
DeleterType is nothrow constructed from other's deleter and must preserve its destruction protocol for the converted pointer. The same deleter type is accepted only when adding cv-qualification. other is left empty. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
operator=¶
UniquePtr & ludus::foundation::core::UniquePtr< ElementType, DeleterType >::operator=(UniquePtr &&other) noexcept
requires std::is_nothrow_move_constructible_v<DeleterType> && std::is_nothrow_move_assignable_v<DeleterType>
other's pointer and deleter. other emptied first, then the previous object is destroyed with its own deleter, then the staged state is installed. The source is never read after the previous object is destroyed, so root = Move(root->Child) is valid. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
operator=¶
UniquePtr & ludus::foundation::core::UniquePtr< ElementType, DeleterType >::operator=(const UniquePtr &)=delete
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
operator=¶
template <typename OtherElementType, typename OtherDeleterType>
UniquePtr & ludus::foundation::core::UniquePtr< ElementType, DeleterType >::operator=(UniquePtr< OtherElementType, OtherDeleterType > &&other) noexcept
requires detail::ImplicitOwnerConversion<OtherElementType, OtherDeleterType, ElementType, DeleterType>
delete owner. other is left empty. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
~UniquePtr¶
ludus::foundation::core::UniquePtr< ElementType, DeleterType >::~UniquePtr()
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
Get¶
LUDUS_INLINE ElementType * ludus::foundation::core::UniquePtr< ElementType, DeleterType >::Get() const noexcept
Returns
nullptr for an empty owner. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
GetDeleter¶
LUDUS_INLINE const DeleterType & ludus::foundation::core::UniquePtr< ElementType, DeleterType >::GetDeleter() const noexcept
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
Release¶
ElementType * ludus::foundation::core::UniquePtr< ElementType, DeleterType >::Release() noexcept
requires detail::BareReleaseDeleter<DeleterType, ElementType>
DefaultDeleter family, including native specializations. Owners with stateful deleters transfer the whole owner instead. Returns
nullptr. The receiver must destroy it with exactly the DefaultDeleter<ElementType> protocol. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
Reset¶
void ludus::foundation::core::UniquePtr< ElementType, DeleterType >::Reset(ElementType *pointerOrNull=nullptr) noexcept
pointerOrNull with the existing deleter. pointerOrNull == Get() leaves the owner unchanged. Otherwise the owner is detached to empty before the previous object is destroyed, then adopts pointerOrNull. | Parameter | Description |
|---|---|
pointerOrNull |
Uniquely owned object matching this owner's deleter protocol, or
nullptr to leave the owner empty. |
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
operator*¶
LUDUS_INLINE ElementType & ludus::foundation::core::UniquePtr< ElementType, DeleterType >::operator*() const noexcept
Precondition
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
operator->¶
LUDUS_INLINE ElementType * ludus::foundation::core::UniquePtr< ElementType, DeleterType >::operator->() const noexcept
Precondition
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
operator bool¶
explicit LUDUS_INLINE ludus::foundation::core::UniquePtr< ElementType, DeleterType >::operator bool() const noexcept
Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp
Swap¶
void ludus::foundation::core::UniquePtr< ElementType, DeleterType >::Swap(UniquePtr &other) noexcept
requires std::is_nothrow_move_constructible_v<DeleterType> && std::is_nothrow_move_assignable_v<DeleterType>
other as one pair. Declared in modules/foundation/base/include/ludus/foundation/base/pointer.hpp