Unless otherwise specified, all containers defined in this Clause obtain memory
using an allocator (see
[allocator.requirements])
. [
Note 2:
In particular, containers and iterators do not store references
to allocated elements other than through the allocator's pointer type,
i.e., as objects of type
P or
pointer_traits<P>::template rebind<unspecified>,
where
P is
allocator_traits<allocator_type>::pointer. —
end note]
Copy constructors for these container types obtain an allocator by calling
allocator_traits<allocator_type>::select_on_container_copy_construction
on the allocator belonging to the container being copied
. Move constructors obtain an allocator by move construction from the allocator belonging to
the container being moved
. Such move construction of the allocator shall not exit via an
exception
. All other constructors for these container types take a
const allocator_type& argument
. [
Note 3:
If an invocation of a constructor uses the default value of an optional
allocator argument, then the allocator type must support value-initialization
. —
end note]
A copy of this allocator is used for any memory allocation and element construction
performed, by these constructors and by all member functions,
during the lifetime of each container object
or until the allocator is replaced
. The allocator may be replaced only via assignment or
swap(). Allocator replacement is performed by
copy assignment, move assignment, or swapping of the allocator only if
- allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value,
- allocator_traits<allocator_type>::propagate_on_container_move_assignment::value,
or
- allocator_traits<allocator_type>::propagate_on_container_swap::value
is
true
within the implementation of the corresponding container operation
. In all container types defined in this Clause, the member
get_allocator()
returns a copy of the allocator used to construct the container or, if that allocator
has been replaced, a copy of the most recent replacement
.