ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
AllocatorAware.h File Reference

The rules of the allocator-aware containers of the standard ([container.reqmts], [allocator.requirements]), beyond the book, written once for the containers of ADS that take an allocator A: a container rebinds A to the type of what it allocates (its nodes, its places, its blocks) by std::allocator_traits, a copy takes the allocator that select_on_container_copy_construction() gives, and a copy assignment, a move assignment and a swap take the allocator of the other container only when the trait propagate_on_container_copy_assignment, propagate_on_container_move_assignment or propagate_on_container_swap of A is true. More...

#include "ADS/Contract.h"
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  ADS

Detailed description

The rules of the allocator-aware containers of the standard ([container.reqmts], [allocator.requirements]), beyond the book, written once for the containers of ADS that take an allocator A: a container rebinds A to the type of what it allocates (its nodes, its places, its blocks) by std::allocator_traits, a copy takes the allocator that select_on_container_copy_construction() gives, and a copy assignment, a move assignment and a swap take the allocator of the other container only when the trait propagate_on_container_copy_assignment, propagate_on_container_move_assignment or propagate_on_container_swap of A is true.

A move assignment between two containers whose allocators are not equal and do not propagate moves the items one by one into memory of the allocator of the target, since its memory must go back to the allocator that gave it; a swap of such containers is not allowed (as in the standard).

Any allocator of the standard plugs in: std::pmr::polymorphic_allocator over a resource (e.g., std::pmr::monotonic_buffer_resource), whose allocators do not propagate; mi_stl_allocator of mimalloc, stateless; an allocator written over mallocx() and sdallocx() of jemalloc; and those of ADS, HugePageAllocator [see HugePageAllocator.h] and PoolAllocator [see PoolAllocator.h] over a PoolResource, a ConcurrentPoolResource or an ArenaResource [see Arena.h], which propagate. With the default allocator of a container, std::allocator or the HugePageAllocator of its ObjectPool [see ObjectPool.h], the code and the layout of the container are those it had before it took an allocator: the default allocator is empty, it takes no room, and the paths that only a stateful allocator needs are compiled out.

Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa