Documentation of memory

( foonathan/memory)

allocator_deallocator< Type, RawAllocator, Mutex > Class Template Reference

Detailed Description

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

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

It deallocates memory for a specified type but does not call its destructors. Only a reference to the RawAllocator is stored, access to it is synchronized by a given Mutex which defaults to default_mutex.


using allocator_type = typename allocator_reference< RawAllocator, Mutex >::allocator_type
using mutex = Mutex
using value_type = Type

Member Functions

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


§ allocator_deallocator()

allocator_deallocator ( allocator_reference< RawAllocator, mutex >  alloc)
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)
Deallocates the memory given to it. Calls deallocate_node(pointer, sizeof(value_type), alignof(value_type)) on the referenced allocator object.

§ get_allocator()

auto get_allocator ( ) const -> decltype( std::declval<allocator_reference<allocator_type, mutex>>().get_allocator())
The reference to the allocator. It has the same type as the call to allocator_reference::get_allocator().