|
CookMem 1.4.0
A C++ memory context / allocator
|
#include <allocator.h>
Classes | |
| struct | rebind |
Public Types | |
| typedef ContextProvider | context_provider_type |
| The type of the context provider. | |
| typedef ContextProvider::context_type | context_type |
| The type of the memory context. | |
| typedef T | value_type |
| The type of the allocated objects. | |
| typedef T * | pointer |
| Pointer to an allocated object. | |
| typedef const T * | const_pointer |
| Const pointer to an allocated object. | |
| typedef T & | reference |
| Reference to an allocated object. | |
| typedef const T & | const_reference |
| Const reference to an allocated object. | |
| typedef std::size_t | size_type |
| The type of object counts. | |
| typedef std::ptrdiff_t | difference_type |
| The type of pointer differences. | |
| typedef ContextProvider::propagate_on_container_copy_assignment | propagate_on_container_copy_assignment |
| typedef ContextProvider::propagate_on_container_move_assignment | propagate_on_container_move_assignment |
| typedef ContextProvider::propagate_on_container_swap | propagate_on_container_swap |
| typedef ContextProvider::is_always_equal | is_always_equal |
Public Member Functions | |
| template<class Provider = ContextProvider> | |
| Allocator (typename std::enable_if< std::is_default_constructible< Provider >::value, int >::type *=nullptr) | |
| Allocator (context_type &context) | |
| Allocator (const ContextProvider &provider) | |
| Allocator (const Allocator &other) | |
| template<class U > | |
| Allocator (const Allocator< U, ContextProvider > &other) | |
| pointer | allocate (size_type size, const void *=nullptr) |
| void | deallocate (pointer ptr, size_type) |
| size_type | max_size () const |
| template<class U , class... Args> | |
| void | construct (U *ptr, Args &&... args) |
| template<class U > | |
| void | destroy (U *ptr) |
| context_type & | getContext () const |
| template<class U > | |
| bool | operator== (const Allocator< U, ContextProvider > &other) const |
| template<class U > | |
| bool | operator!= (const Allocator< U, ContextProvider > &other) const |
An STL allocator that allocates through its context provider.
Allocator copies and rebound allocators retain the same provider.
Types that require an alignment larger than ALLOCATION_ALIGNMENT are allocated with the allocateAligned () function of the context. Other types only need the context to provide allocate ().
| typedef ContextProvider::is_always_equal cookmem::Allocator< T, ContextProvider >::is_always_equal |
Same as the context provider.
| typedef ContextProvider::propagate_on_container_copy_assignment cookmem::Allocator< T, ContextProvider >::propagate_on_container_copy_assignment |
Same as the context provider.
| typedef ContextProvider::propagate_on_container_move_assignment cookmem::Allocator< T, ContextProvider >::propagate_on_container_move_assignment |
Same as the context provider.
| typedef ContextProvider::propagate_on_container_swap cookmem::Allocator< T, ContextProvider >::propagate_on_container_swap |
Same as the context provider.
|
inline |
Default constructor. It is available only when the context provider is default constructible, such as TLSContextProvider.
|
inlineexplicit |
Constructor.
| context | the memory context to allocate from. It must outlive every container that uses this allocator. |
|
inlineexplicit |
Constructor.
| provider | the context provider to copy. |
|
inline |
Copy constructor. The copy uses the same memory context.
| other | the allocator to copy. |
|
inline |
Converting constructor from an allocator for a different object type. The new allocator uses the same memory context.
| other | the allocator to copy. |
|
inline |
Allocate memory for a number of objects. The objects are not constructed.
| size | the number of objects. |
| std::bad_alloc | if the memory cannot be allocated. |
|
inline |
Construct an object in allocated memory.
| ptr | where to construct the object. |
| args | the constructor arguments. |
|
inline |
Deallocate memory obtained from allocate (). The objects must have been destroyed already.
| ptr | the memory to deallocate. |
|
inline |
Destroy an object without deallocating its memory.
| ptr | the object to destroy. |
|
inline |
Get the memory context.
|
inline |
Get the largest number of objects that could be requested.
|
inline |
Check if two allocators use different memory contexts.
| other | the allocator to compare with. |
|
inline |
Check if memory allocated by one allocator can be deallocated by the other.
| other | the allocator to compare with. |