|
ecor
|
Allocator that uses reference to circular_buffer_memory for allocating memory. More...
#include <ecor.hpp>
Classes | |
| struct | rebind |
Public Types | |
| using | difference_type = std::ptrdiff_t |
| using | size_type = std::size_t |
| using | value_type = T |
Public Member Functions | |
| T * | allocate (std::size_t n) |
| Allocate memory for n objects of type T, returns pointer to the allocated memory. More... | |
| circular_buffer_allocator (circular_buffer_allocator const &) noexcept=default | |
| Copy constructor, allows copying the allocator. More... | |
| template<typename U > | |
| circular_buffer_allocator (circular_buffer_allocator< U, IndexType, Base > const &other) noexcept | |
| Template copy constructor, allows copying from an allocator of a different type. More... | |
| circular_buffer_allocator (circular_buffer_memory< IndexType, Base > &buffer) noexcept | |
| Construct an allocator that uses the given circular_buffer_memory for allocations. | |
| void | deallocate (T *ptr, std::size_t n) |
| Deallocate memory previously allocated by allocate(). More... | |
| bool | operator!= (circular_buffer_allocator const &other) const noexcept |
| Inequality comparison operator, defined in terms of operator==. | |
| bool | operator== (circular_buffer_allocator const &other) const noexcept |
| Equality comparison operators, allocators are equal if they refer to the same circular_buffer_memory. | |
Friends | |
| template<typename U , typename IdxType , typename Base2 > | |
| struct | circular_buffer_allocator |
| Grant access to other allocator types for copying. More... | |
Allocator that uses reference to circular_buffer_memory for allocating memory.
This can be used to create standard library containers that use circular_buffer_memory for their allocations.
The template parameters are:
T: The type of objects to allocate.IndexType: The index type used by the circular_buffer_memory.Base: The base class used by the circular_buffer_memory, included here for compatibility with circular_buffer_memory's template parameters.
|
defaultnoexcept |
Copy constructor, allows copying the allocator.
The copied allocator will refer to the same circular_buffer_memory.
|
inlinenoexcept |
Template copy constructor, allows copying from an allocator of a different type.
The copied allocator will refer to the same circular_buffer_memory.
|
inline |
Allocate memory for n objects of type T, returns pointer to the allocated memory.
The memory is allocated from the circular_buffer_memory associated with this allocator. The returned pointer is valid until the memory resource is destroyed or the memory is deallocated.
Throws std::bad_alloc if allocation fails.
|
inline |
Deallocate memory previously allocated by allocate().
The pointer must have been returned by a previous call to allocate() on this allocator, and the size n must match the size used in that call. The memory is deallocated back to the circular_buffer_memory associated with this allocator.
|
friend |
Grant access to other allocator types for copying.
This allows allocators of different types to access each other's internal buffer pointer when copying.