memory
Typedefs | Member Functions
allocator_deallocator< Type, RawAllocator > Class Template Reference

Detailed Description

template<typename Type, class RawAllocator>
class foonathan::memory::allocator_deallocator< Type, RawAllocator >

A deleter class that deallocates the memory through a specified RawAllocator.

It deallocates memory for a specified type but does not call its destructors.

Typedefs

using allocator_type = typename allocator_reference< RawAllocator >::allocator_type
 
using value_type = Type
 

Member Functions

 allocator_deallocator () noexcept=default
 
 allocator_deallocator (allocator_reference< RawAllocator > alloc) noexcept
 
void operator() (value_type *pointer) noexcept
 
auto get_allocator () const noexcept -> decltype(std::declval< allocator_reference< allocator_type > >().get_allocator())
 

Constructors

◆ allocator_deallocator() [1/2]

allocator_deallocator ( )
defaultnoexcept
Effects:
Creates it without any associated allocator. The deallocator must not be used if that is the case.
Notes:
This functions is useful if you have want to create an empty smart pointer without giving it an allocator.

◆ allocator_deallocator() [2/2]

allocator_deallocator ( allocator_reference< RawAllocator >  alloc)
noexcept
Effects:
Creates it by passing it an allocator_reference. It will store the reference to it and uses the referenced allocator object for the deallocation.

Member Functions

◆ operator()()

void operator() ( value_type *  pointer)
noexcept
Effects:
Deallocates the memory given to it. Calls deallocate_node(pointer, sizeof(value_type), alignof(value_type)) on the referenced allocator object.
Requires:
The deallocator must not have been created by the default constructor.

◆ get_allocator()

auto get_allocator ( ) const -> decltype(std::declval<allocator_reference<allocator_type>>().get_allocator())
noexcept
Returns:
The reference to the allocator. It has the same type as the call to allocator_reference::get_allocator().
Requires:
The deallocator must not be created by the default constructor.