memory
Typedefs | Member Functions
memory_resource_adapter< RawAllocator > Class Template Referenceabstract

Detailed Description

template<class RawAllocator>
class foonathan::memory::memory_resource_adapter< RawAllocator >

Wraps a RawAllocator and makes it a memory_resource.

Typedefs

using allocator_type = typename allocator_traits< RawAllocator >::allocator_type
 

Member Functions

 memory_resource_adapter (allocator_type &&other) noexcept
 
void * allocate (std::size_t bytes, std::size_t alignment=max_alignment)
 
void deallocate (void *p, std::size_t bytes, std::size_t alignment=max_alignment)
 
bool is_equal (const memory_resource &other) const noexcept
 
allocator_type & get_allocator () noexcept
 
const allocator_type & get_allocator () const noexcept
 

Constructors

◆ memory_resource_adapter()

memory_resource_adapter ( allocator_type &&  other)
noexcept
Effects:
Creates the resource by moving in the allocator.

Member Functions

◆ get_allocator() [1/2]

allocator_type & get_allocator ( )
noexcept
Returns:
A reference to the wrapped allocator.

◆ get_allocator() [2/2]

const allocator_type & get_allocator ( ) const
noexcept
Returns:
A reference to the wrapped allocator.

◆ do_allocate()

void * do_allocate ( std::size_t  bytes,
std::size_t  alignment 
)
overrideprotected
Effects:
Allocates raw memory with given size and alignment. It forwards to allocate_node() or allocate_array() depending on the size.
Returns:
The new memory as returned by the RawAllocator.
Throws:
Anything thrown by the allocation function.

◆ do_deallocate()

void do_deallocate ( void *  p,
std::size_t  bytes,
std::size_t  alignment 
)
overrideprotected
Effects:
Deallocates memory previously allocated by do_allocate. It forwards to deallocate_node() or deallocate_array() depending on the size.
Throws:
Nothing.

◆ do_is_equal()

bool do_is_equal ( const memory_resource other) const
overrideprotectednoexcept
Returns:
Whether or not *this is equal to other by comparing the addresses.