An allocator whose pointer type is cptr::ptr, so that containers that take their link type from the allocator get 4-byte links.
Declared in <cptr/fancy_allocator.hpp>
template<
class T,
class Cage = default_cage>
class fancy_allocator;
plf::list is one such container. Its nodes link to a sentinel inside the list object, so the list object must be in the cage as well.
using list = plf::list<int, cptr::fancy_allocator<int>>;
cptr::ptr<list> l = cptr::make<list>(); // the list object in the cage
l->push_back(1);
cptr::destroy(l);
| Name | Description |
|---|---|
rebind | The same allocator for another element type. |
| Name | Description |
|---|---|
const_pointer | A compressed pointer to a const element. |
const_void_pointer | A compressed const void*. |
difference_type | The type of pointer differences. |
pointer | A compressed pointer to an element. |
size_type | The type of element counts. |
value_type | The element type. |
void_pointer | A compressed void*. |
| Name | Description |
|---|---|
fancy_allocator [constructor] | Constructors |
allocate | Memory for n T in the cage, uninitialised. Throws std::bad_array_new_length if n exceeds max_size(), and std::bad_alloc when the cage is full. |
construct | construct overloads |
deallocate | Frees memory from allocate(); the elements must already be destroyed. |
destroy | destroy overloads |
max_size | The most T that one allocation could hold: no more than fit in the cage. |
| Name | Description |
|---|---|
cptr::operator== | Always true: memory from one fancy_allocator for a cage can be freed by any other for the same cage. |