Documentation of memory

( foonathan/memory)

Adapters and Wrappers

Classes

class  aligned_allocator< RawAllocator >
 A RawAllocator adapter that ensures a minimum alignment. More...
 
class  vector< T, RawAllocator, Mutex >
 Alias template for an STL container that uses a certain RawAllocator. More...
 
struct  forward_list_node_size< T >
 Contains the node size of a node based STL container with a specific type. More...
 
class  allocator_deallocator< Type, RawAllocator, Mutex >
 A deleter class that deallocates the memory through a specified RawAllocator. More...
 
class  allocator_deallocator< Type[], RawAllocator, Mutex >
 Specialization of allocator_deallocator for array types. More...
 
class  allocator_deleter< Type, RawAllocator, Mutex >
 Similar to allocator_deallocator but calls the destructors of the objects. More...
 
class  allocator_deleter< Type[], RawAllocator, Mutex >
 Specialization of allocator_deleter for array types. More...
 
class  fallback_allocator< Default, Fallback >
 A RawAllocator with a fallback. More...
 
class  growing_block_allocator< RawAllocator, Num, Den >
 A BlockAllocator that uses a given RawAllocator for allocating the blocks. More...
 
class  fixed_block_allocator< RawAllocator >
 A BlockAllocator that allows only one block allocation. More...
 
class  memory_resource
 The memory_resource abstract base class used in the implementation. More...
 
class  memory_resource_adapter< RawAllocator >
 Wraps a RawAllocator and makes it a memory_resource. More...
 
class  memory_resource_allocator
 Wraps a memory_resource and makes it a RawAllocator. More...
 
struct  is_shared_allocator< memory_resource_allocator >
 Specialization of is_shared_allocator to mark memory_resource_allocator as shared. More...
 
class  unique_ptr< T, RawAllocator >
 A std::unique_ptr that deletes using a RawAllocator. More...
 
struct  shared_ptr_node_size< T >
 Contains the node size needed for a std::shared_ptr. More...
 
struct  propagation_traits< RawAllocator >
 Controls the propagation of a std_allocator for a certain RawAllocator. More...
 
class  std_allocator< T, RawAllocator, Mutex >
 Wraps a RawAllocator and makes it a "normal" Allocator. More...
 
class  any_std_allocator< T, Mutex >
 An alias template for std_allocator using a type-erased RawAllocator. More...
 
class  tracked_block_allocator< Tracker, BlockOrRawAllocator >
 A BlockAllocator adapter that tracks another allocator using a tracker. More...
 
class  tracked_allocator< Tracker, RawAllocator >
 A RawAllocator adapter that tracks another allocator using a tracker. More...
 
class  deeply_tracked_allocator< Tracker, RawAllocator >
 A tracked_allocator that has rebound any BlockAllocator to the corresponding deeply_tracked_block_allocator. More...
 

Typedefs

template<class Tracker , class BlockOrRawAllocator >
using deeply_tracked_block_allocator = implementation_defined
 Similar to tracked_block_allocator, but shares the tracker with the higher level allocator. More...
 

Functions

template<typename T , class RawAllocator , typename... Args>
auto allocate_unique (RawAllocator &&alloc, Args &&... args) -> allocator_deleter< T, typename std::decay< RawAllocator >::type >>)
 Creates a std::unique_ptr using a RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator , typename... Args>
auto allocate_unique (any_allocator, RawAllocator &&alloc, Args &&... args) -> allocator_deleter< T, any_allocator >>)
 Creates a std::unique_ptr using a type-erased RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator >
auto allocate_unique (RawAllocator &&alloc, std::size_t size) -> allocator_deleter< T, typename std::decay< RawAllocator >::type >>)
 Creates a std::unique_ptr owning an array using a RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator >
auto allocate_unique (any_allocator, RawAllocator &&alloc, std::size_t size) -> allocator_deleter< T, any_allocator >>)
 Creates a std::unique_ptr owning an array using a type-erased RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator , typename... Args>
std::shared_ptr< T > allocate_shared (RawAllocator &&alloc, Args &&... args)
 Creates a std::shared_ptr using a RawAllocator for the allocation. More...
 
template<typename T , class RawAllocator , class Container = deque<T, RawAllocator>>
std::stack< T, Container > make_stack (RawAllocator &allocator)
 
template<typename T , class RawAllocator , class Container = deque<T, RawAllocator>>
std::queue< T, Container > make_queue (RawAllocator &allocator)
 
template<typename T , class RawAllocator , class Container = deque<T, RawAllocator>, class Compare = std::less<T>>
std::priority_queue< T, Container, Compare > make_priority_queue (RawAllocator &allocator, Compare comp={})
 

Typedefs

§ deeply_tracked_block_allocator

using deeply_tracked_block_allocator = implementation_defined

Similar to tracked_block_allocator, but shares the tracker with the higher level allocator.

This allows tracking both (de-)allocations and growth with one tracker.

Note
Due to implementation reasons, it cannot track growth and shrinking in the constructor/destructor of the higher level allocator.

Functions

§ make_stack()

std::stack<T, Container> foonathan::memory::make_stack ( RawAllocator &  allocator)

Convenience function to create a container adapter using a certain RawAllocator.

Returns:
An empty adapter with an implementation container using a reference to a given allocator.

§ allocate_unique() [1/4]

auto foonathan::memory::allocate_unique ( RawAllocator &&  alloc,
Args &&...  args 
) -> allocator_deleter<T, typename std::decay<RawAllocator>::type>>)

Creates a std::unique_ptr using a RawAllocator for the allocation.

Effects:
Allocates memory for the given type using the allocator and creates a new object inside it passing the given arguments to its constructor.
Returns:
A std::unique_ptr owning that memory.
Note
If the allocator is stateful a reference to the RawAllocator will be stored inside the deleter, the caller has to ensure that the object lives as long as the smart pointer.

§ allocate_unique() [2/4]

auto foonathan::memory::allocate_unique ( any_allocator  ,
RawAllocator &&  alloc,
Args &&...  args 
) -> allocator_deleter<T, any_allocator>>)

Creates a std::unique_ptr using a type-erased RawAllocator for the allocation.

It is the same as the other overload but stores the reference to the allocator type-erased inside the std::unique_ptr.

Effects:
Allocates memory for the given type using the allocator and creates a new object inside it passing the given arguments to its constructor.
Returns:
A std::unique_ptr with a type-erased allocator reference owning that memory.
Note
If the allocator is stateful a reference to the RawAllocator will be stored inside the deleter, the caller has to ensure that the object lives as long as the smart pointer.

§ allocate_unique() [3/4]

auto foonathan::memory::allocate_unique ( RawAllocator &&  alloc,
std::size_t  size 
) -> allocator_deleter<T, typename std::decay<RawAllocator>::type>>)

Creates a std::unique_ptr owning an array using a RawAllocator for the allocation.

Effects:
Allocates memory for an array of given size and value initializes each element inside of it.
Returns:
A std::unique_ptr owning that array.
Note
If the allocator is stateful a reference to the RawAllocator will be stored inside the deleter, the caller has to ensure that the object lives as long as the smart pointer.

§ allocate_unique() [4/4]

auto foonathan::memory::allocate_unique ( any_allocator  ,
RawAllocator &&  alloc,
std::size_t  size 
) -> allocator_deleter<T, any_allocator>>)

Creates a std::unique_ptr owning an array using a type-erased RawAllocator for the allocation.

It is the same as the other overload but stores the reference to the allocator type-erased inside the std::unique_ptr.

Effects:
Allocates memory for an array of given size and value initializes each element inside of it.
Returns:
A std::unique_ptr with a type-erased allocator reference owning that array.
Note
If the allocator is stateful a reference to the RawAllocator will be stored inside the deleter, the caller has to ensure that the object lives as long as the smart pointer.

§ allocate_shared()

std::shared_ptr<T> foonathan::memory::allocate_shared ( RawAllocator &&  alloc,
Args &&...  args 
)

Creates a std::shared_ptr using a RawAllocator for the allocation.

It is similar to std::allocate_shared but uses a RawAllocator (and thus also supports any Allocator).

Effects:
Calls std_allocator::make_std_allocator to wrap the allocator and forwards to std::allocate_shared.
Returns:
A std::shared_ptr created using std::allocate_shared.
Note
If the allocator is stateful a reference to the RawAllocator will be stored inside the shared pointer, the caller has to ensure that the object lives as long as the smart pointer.

§ make_queue()

std::queue<T, Container> foonathan::memory::make_queue ( RawAllocator &  allocator)

Convenience function to create a container adapter using a certain RawAllocator.

Returns:
An empty adapter with an implementation container using a reference to a given allocator.

§ make_priority_queue()

std::priority_queue<T, Container, Compare> foonathan::memory::make_priority_queue ( RawAllocator &  allocator,
Compare  comp = {} 
)

Convenience function to create a container adapter using a certain RawAllocator.

Returns:
An empty adapter with an implementation container using a reference to a given allocator.