Documentation of memory

( foonathan/memory)

new_allocator Class Reference

Detailed Description

A stateless RawAllocator that allocates memory using operator new.

Typedefs

using is_stateful = std::false_type
 

Member Functions

 new_allocator (new_allocator &&) noexcept
 
new_allocatoroperator= (new_allocator &&) noexcept
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void deallocate_node (void *node, std::size_t size, std::size_t alignment) noexcept
 
std::size_t max_node_size () const noexcept
 

Member Functions

void* allocate_node ( std::size_t  size,
std::size_t  alignment 
)
Effects:
A RawAllocator allocation function. It uses the nothrow operator new, if it returns nullptr, it behaves like new and loops calling std::new_handler, but instead of throwing std::bad_alloc, it throws out_of_memory at the end.
Returns:
A pointer to a node, it will never be nullptr.
Throws:
An exception of type out_of_memory or whatever is thrown by its handler if the allocation fails.
void deallocate_node ( void *  node,
std::size_t  size,
std::size_t  alignment 
)
noexcept
Effects:
A RawAllocator deallocation function. It uses operator delete
std::size_t max_node_size ( ) const
noexcept
Returns:
The maximum node size by forwaring to std::allocator<char>::max_size() or the maximum value on a freestanding implementation.