Skip to content

ludus::foundation::DomainDeleter

Ludus Wiki · API overview · Browse API

Class

Destroys one exact object and frees its storage through its original domain.
Stores only the domain pointer; sizeof(T) and alignof(T) come from the element type, so an owner of an exact type is two pointer words. The only supported conversion adds const through the explicit adapter constructor; Derived-to-Base ownership is rejected because a base view can neither recover the original allocation address nor its size.
A default-constructed deleter has no domain. It is valid for an empty owner (for example an output passed to TryCreateOwned) but must never be invoked.
Template parameterDescription
ElementType
Exact owned object type, optionally const-qualified. It may be incomplete where an owner is declared (PIMPL); it must be a complete, nothrow-destructible, non-array type wherever the deleter is invoked.

Note

The domain and its callback context must outlive every owner holding a deleter bound to it.

Declared in modules/foundation/memory/include/ludus/foundation/memory/owned_object.hpp

#include <ludus/foundation/memory/owned_object.hpp>
template <typename ElementType>
class ludus::foundation::DomainDeleter final

Methods

DomainDeleter

constexpr ludus::foundation::DomainDeleter< ElementType >::DomainDeleter() noexcept=default
Constructs a deleter without a domain, for an empty owner only.

Declared in modules/foundation/memory/include/ludus/foundation/memory/owned_object.hpp

DomainDeleter

explicit constexpr ludus::foundation::DomainDeleter< ElementType >::DomainDeleter(const AllocationDomain &domain) noexcept
Binds the deleter to the domain that allocated the owned object.
ParameterDescription
domain
Domain whose TryAllocate returned the object's storage. Borrowed; it must outlive the deleter and every owner holding it.

Related types: AllocationDomain

Declared in modules/foundation/memory/include/ludus/foundation/memory/owned_object.hpp

DomainDeleter

template <typename OtherElementType>
explicit constexpr ludus::foundation::DomainDeleter< ElementType >::DomainDeleter(DomainDeleter< OtherElementType > &&other) noexcept
requires (std::is_same_v<std::add_const_t<OtherElementType>, ElementType> && std::is_same_v<OtherElementType, ElementType> == false)
Adapts the deleter of a mutable exact object to its const view.
Adding const never adjusts the object address, so the domain and layout remain correct. Use it through the explicit UniquePtr adapter conversion.
ParameterDescription
other
Deleter of the same object type without the added const.

Declared in modules/foundation/memory/include/ludus/foundation/memory/owned_object.hpp

GetDomainOrNull

LUDUS_INLINE const AllocationDomain * ludus::foundation::DomainDeleter< ElementType >::GetDomainOrNull() const noexcept
Inspects the domain that frees the owned object.

Returns

The bound domain, or nullptr for a default-constructed deleter.

Related types: AllocationDomain

Declared in modules/foundation/memory/include/ludus/foundation/memory/owned_object.hpp

operator()

void ludus::foundation::DomainDeleter< ElementType >::operator()(ElementType *pointer) const noexcept
Destroys pointer and frees its exact layout through the bound domain.
ParameterDescription
pointer
Object created by TryCreateOwned through the bound domain. UniquePtr never passes nullptr.

Precondition

The deleter is bound to a live domain. Violations terminate through LUDUS_REQUIRE rather than freeing through an unknown backend.

Declared in modules/foundation/memory/include/ludus/foundation/memory/owned_object.hpp