This Clause describes components that C++ programs may use to
organize collections of information.

Table 74: Containers library summary [tab:containers.summary]

Subclause | Header | ||

Requirements | |||

Sequence containers | <array>, <deque>, <forward_list>,
<list>, <vector> | ||

Associative containers | <map>, <set> | ||

Unordered associative containers | <unordered_map>, <unordered_set> | ||

Container adaptors | <queue>, <stack> | ||

Views | <span> |

All of the complexity requirements in this Clause are stated solely
in terms of the number of operations on the contained objects.

For the components affected by this subclause that declare an allocator_type,
objects stored in these components shall be constructed using the function
allocator_traits<allocator_type>::rebind_traits<U>::construct
and destroyed using the function
allocator_traits<allocator_type>::rebind_traits<U>::destroy,
where U is either allocator_type::value_type or
an internal type used by the container.

These functions are called only for the
container's element type, not for internal types used by the container.

Table 75: Container requirements [tab:container.req]

Expression | Return type | Operational | Assertion/note | Complexity | |

semantics | pre-/post-condition | ||||

X::value_type | T | compile time | |||

X::reference | T& | compile time | |||

X::const_reference | const T& | compile time | |||

X::iterator | iterator type whose value type is T | compile time | |||

X::const_iterator | constant iterator type whose value type is T | any iterator category
that meets the forward iterator requirements. | compile time | ||

X::difference_type | signed integer type | is identical to the difference type of X::iterator and X::const_iterator | compile time | ||

X::size_type | unsigned integer type | size_type can represent any non-negative value of difference_type | compile time | ||

X u; | Postconditions: u.empty() | constant | |||

X() | Postconditions: X().empty() | constant | |||

X(a) | linear | ||||

X u(a); X u = a; | Postconditions: u == a | linear | |||

X u(rv); X u = rv; | Postconditions: u is equal to the value that rv had before this construction | (Note B) | |||

a = rv | X& | All existing elements of a are either move assigned to or destroyed | Postconditions: If a and rv do not refer to the same object,
a is equal to the value that rv
had before this assignment. | linear | |

a.~X() | void | linear | |||

a.begin() | iterator; const_iterator for constant a | constant | |||

a.end() | iterator; const_iterator for constant a | constant | |||

a.cbegin() | const_iterator | const_cast<X const&>(a).begin(); | constant | ||

a.cend() | const_iterator | const_cast<X const&>(a).end(); | constant | ||

i <=> j | strong_ordering | constant | |||

a == b | convertible to bool | == is an equivalence relation. equal(a.begin(), a.end(), b.begin(), b.end()) | Preconditions: T meets the Cpp17EqualityComparable requirements | Constant if a.size() != b.size(),
linear otherwise | |

a != b | convertible to bool | Equivalent to !(a == b) | linear | ||

a.swap(b) | void | Effects: exchanges the contents of a and b | (Note A) | ||

swap(a, b) | void | Equivalent to a.swap(b) | (Note A) | ||

r = a | X& | linear | |||

a.size() | size_type | distance(a.begin(), a.end()) | constant | ||

a.max_size() | size_type | distance(begin(), end())
for the largest possible container | constant | ||

a.empty() | convertible to bool | a.begin() == a.end() | constant |

Those entries marked “(Note A)” or “(Note B)”
have linear complexity for array and have constant complexity
for all other standard containers.

In the expressions
i == j
i != j
i < j
i <= j
i >= j
i > j
i <=> j
i - j
where i and j denote objects of a container's iterator
type, either or both may be replaced by an object of the container's
const_iterator type referring to the same element with no change in semantics.

Unless otherwise specified, all containers defined in this Clause obtain memory
using an allocator (see [allocator.requirements]).

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.

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

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.

The expression a.swap(b), for containers a and b of a standard
container type other than array, shall exchange the values of a and
b without invoking any move, copy, or swap operations on the individual
container elements.

Lvalues of any Compare, Pred, or Hash types
belonging to a and b shall be swappable
and shall be exchanged by calling swap
as described in [swappable.requirements].

If
allocator_traits<allocator_type>::propagate_on_container_swap::value is
true, then
lvalues of type allocator_type shall be swappable and
the allocators of a and b shall also be exchanged
by calling swap as described in [swappable.requirements].

Otherwise, the allocators shall not be swapped, and the behavior is
undefined unless a.get_allocator() == b.get_allocator().

Every iterator
referring to an element in one container before the swap shall refer to the same
element in the other container after the swap.

It is unspecified whether an iterator
with value a.end() before the swap will have value b.end() after the
swap.

If the iterator type of a container belongs to the bidirectional or
random access iterator categories,
the container is called
*reversible*
and meets the additional requirements
in Table 76.

Table 76: Reversible container requirements [tab:container.rev.req]

Expression | Return type | Assertion/note | Complexity | |

pre-/post-condition | ||||

X::reverse_iterator | iterator type whose value type is T | reverse_iterator<iterator> | compile time | |

X::const_reverse_iterator | constant iterator type whose value type is T | reverse_iterator<const_iterator> | compile time | |

a.rbegin() | reverse_iterator; const_reverse_iterator for constant a | reverse_iterator(end()) | constant | |

a.rend() | reverse_iterator; const_reverse_iterator for constant a | reverse_iterator(begin()) | constant | |

a.crbegin() | const_reverse_iterator | const_cast<X const&>(a).rbegin() | constant | |

a.crend() | const_reverse_iterator | const_cast<X const&>(a).rend() | constant |

Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers], and
[vector.modifiers])
all container types defined in this Clause meet
the following additional requirements:

- if an exception is thrown by an insert() or emplace() function while inserting a single element, that function has no effects.
- if an exception is thrown by a push_back(), push_front(), emplace_back(), or emplace_front() function, that function has no effects.
- no copy constructor or assignment operator of a returned iterator throws an exception.
- no swap() function throws an exception.

Unless otherwise specified (either explicitly or by defining a
function in terms of other functions), invoking a container member
function or passing a container as an argument to a library function
shall not invalidate iterators to, or change the values of, objects
within that container.

A *contiguous container*
is a container
whose member types iterator and const_iterator
meet the
*Cpp17RandomAccessIterator* requirements ([random.access.iterators]) and
model contiguous_iterator ([iterator.concept.contiguous]).

Those containers for which the
listed operations are provided shall implement the semantics described in
Table 77 unless otherwise stated.

If the iterators passed to lexicographical_compare_three_way
meet the constexpr iterator requirements ([iterator.requirements.general])
then the operations described in Table 77
are implemented by constexpr functions.

Table 77: Optional container operations [tab:container.opt]

Expression | Return type | Operational | Assertion/note | Complexity | |

semantics | pre-/post-condition | ||||

a <=> b | synth-three-way-result<value_type> | lexicographical_compare_three_way(a.begin(), a.end(),
b.begin(), b.end(), synth-three-way) | Preconditions: Either <=> is defined for values of type (possibly const) T,
or < is defined for values of type (possibly const) T and
< is a total ordering relationship. | linear |

All of the containers defined in this Clause and in [basic.string] except array
meet the additional requirements of an allocator-aware container, as described in
Table 78.

Given an allocator type A
and given a container type X having a value_type identical to T
and an allocator_type identical to allocator_traits<A>::rebind_alloc<T>
and given an lvalue m of type A,
a pointer p of type T*,
an expression v of type (possibly const) T,
and an rvalue rv of type T,
the following terms are defined.

If X
is not allocator-aware, the terms below are defined as if A were
allocator<T> — no allocator object needs to be created
and user specializations of allocator<T> are not instantiated:

- T is
means that the following expression is well-formed: allocator_traits<A>::construct(m, p)*Cpp17DefaultInsertable*into X - An element of X is
*default-inserted*if it is initialized by evaluation of the expression allocator_traits<A>::construct(m, p) where p is the address of the uninitialized storage for the element allocated within X. - T is
means that the following expression is well-formed: allocator_traits<A>::construct(m, p, rv) and its evaluation causes the following postcondition to hold: The value of *p is equivalent to the value of rv before the evaluation.*Cpp17MoveInsertable*into X - T is
means that, in addition to T being*Cpp17CopyInsertable*into X*Cpp17MoveInsertable*into X, the following expression is well-formed: allocator_traits<A>::construct(m, p, v) and its evaluation causes the following postcondition to hold: The value of v is unchanged and is equivalent to *p. - T is
, for zero or more arguments args, means that the following expression is well-formed: allocator_traits<A>::construct(m, p, args)*Cpp17EmplaceConstructible*into X from args - T is
means that the following expression is well-formed: allocator_traits<A>::destroy(m, p)*Cpp17Erasable*from X

Table 78: Allocator-aware container requirements [tab:container.alloc.req]

Expression | Return type | Assertion/note | Complexity | |

pre-/post-condition | ||||

allocator_type | A | compile time | ||

get_- allocator() | A | constant | ||

X() X u; | Postconditions: u.empty() returns true,
u.get_allocator() == A() | constant | ||

X(m) | Postconditions: u.empty() returns true, | constant | ||

X u(m); | u.get_allocator() == m | |||

X(t, m) X u(t, m); | Postconditions: u == t, u.get_allocator() == m | linear | ||

X(rv) X u(rv); | Postconditions: u has the same elements as rv had before this
construction; the value of u.get_allocator() is the same as the
value of rv.get_allocator() before this construction. | constant | ||

X(rv, m) X u(rv, m); | Postconditions: u has the same elements,
or copies of the elements, that rv had before
this construction, u.get_allocator() == m | constant if m == rv.get_allocator(), otherwise linear | ||

a = t | X& | Postconditions: a == t | linear | |

a = rv | X& | linear | ||

a.swap(b) | void | Effects: exchanges the contents of a and b | constant |

The behavior of certain container member functions and deduction guides
depends on whether types qualify as input iterators or allocators.

The extent to which an implementation determines that a type cannot be an input
iterator is unspecified, except that as a minimum integral types shall not qualify
as input iterators.

Likewise, the extent to which an implementation determines that a type cannot be
an allocator is unspecified, except that as a minimum a type A shall not qualify
as an allocator unless it meets both of the following conditions:

- The expression declval<A&>().allocate(size_t{}) is well-formed when treated as an unevaluated operand.

For purposes of avoiding data races, implementations shall
consider the following functions to be const: begin, end,
rbegin, rend, front, back, data, find,
lower_bound, upper_bound, equal_range, at and, except in
associative or unordered associative containers, operator[].

Notwithstanding [res.on.data.races], implementations are required to avoid data
races when the contents of the contained object in different elements in the same
container, excepting vector<bool>, are modified concurrently.

A sequence container organizes a finite set of objects, all of the same type, into a strictly
linear arrangement.

The library provides four basic kinds of sequence containers:
vector, forward_list, list, and deque.

In addition,
array is provided as a sequence container which provides limited sequence operations
because it has a fixed number of elements.

The library also provides container adaptors that
make it easy to construct abstract data types, such as stacks or queues, out of
the basic sequence container kinds (or out of other kinds of sequence containers that the user defines).

[*Note 1*: *end note*]

The sequence containers
offer the programmer different complexity trade-offs.

vector
is appropriate in most circumstances.

array
has a fixed size known during translation.

deque
supports efficient insertions and deletions taking place at the beginning or at the
end of the sequence.

When choosing a container, remember vector is best;
leave a comment to explain if you choose from the rest!

— In Tables 79
and 80,

- X denotes a sequence container class,
- a denotes a value of type X containing elements of type T,
- u denotes the name of a variable being declared,
- A denotes X::allocator_type if the
*qualified-id*X::allocator_type is valid and denotes a type ([temp.deduct]) and allocator<T> if it doesn't, - i and j denote iterators that meet the
*Cpp17InputIterator*requirements and refer to elements implicitly convertible to value_type, - [i, j) denotes a valid range,
- il designates an object of type initializer_list<value_type>,
- n denotes a value of type X::size_type,
- p denotes a valid constant iterator to a,
- q denotes a valid dereferenceable constant iterator to a,
- [q1, q2) denotes a valid range of constant iterators in a,
- t denotes an lvalue or a const rvalue of X::value_type, and
- Args denotes a template parameter pack;

The complexities of the expressions are sequence dependent.

Table 79: Sequence container requirements (in addition to container) [tab:container.seq.req]

Expression | Return type | Assertion/note | |

pre-/post-condition | |||

X(n, t) X u(n, t); | Postconditions: distance(begin(), end()) == nEffects: Constructs a sequence container with n copies of t | ||

X(i, j) X u(i, j); | For vector, if the iterator does
not meet the Cpp17ForwardIterator requirements ([forward.iterators]), T
is also
Cpp17MoveInsertable into X.Postconditions: distance(begin(), end()) ==
distance(i, j)Effects: Constructs a sequence container equal to the range [i, j).Each iterator in the range [i, j) is dereferenced exactly once. | ||

X(il) | Equivalent to X(il.begin(), il.end()) | ||

a = il | X& | ||

a.emplace(p, args) | iterator | ||

a.insert(p,t) | iterator | ||

a.insert(p,rv) | iterator | ||

a.insert(p,n,t) | iterator | ||

a.insert(p,i,j) | iterator | For vector and deque, T is also
Cpp17MoveInsertable into X, Cpp17MoveConstructible, Cpp17MoveAssignable,
and swappable ([swappable.requirements]).Each iterator in the range [i, j) shall be dereferenced exactly once. | |

a.insert(p, il) | iterator | a.insert(p, il.begin(), il.end()). | |

a.erase(q) | iterator | ||

a.erase(q1,q2) | iterator | ||

a.clear() | void | ||

a.assign(i,j) | void | For vector, if the iterator does not
meet the forward iterator requirements ([forward.iterators]), T
is also
Cpp17MoveInsertable into X.Invalidates all references, pointers and iterators
referring to the elements of a. Each iterator in the range [i, j) shall be dereferenced exactly once. | |

a.assign(il) | void | a.assign(il.begin(), il.end()). | |

a.assign(n,t) | void | Invalidates all references, pointers and iterators
referring to the elements of a. |

The iterator returned from a.insert(p, n, t) points to the copy of the first
element inserted into a, or p if n == 0.

The iterator returned from a.insert(p, i, j) points to the copy of the first
element inserted into a, or p if i == j.

The iterator returned from a.insert(p, il) points to the copy of the first
element inserted into a, or p if il is empty.

The iterator returned from a.emplace(p, args) points to the new element
constructed from args into a.

For every sequence container defined in this Clause and in [strings]:

- If the constructor template<class InputIterator> X(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type()); is called with a type InputIterator that does not qualify as an input iterator, then the constructor shall not participate in overload resolution.
- If the member functions of the forms:
template<class InputIterator>
*return-type**F*(const_iterator p, InputIterator first, InputIterator last); // such as insert template<class InputIterator>*return-type**F*(InputIterator first, InputIterator last); // such as append, assign template<class InputIterator>*return-type**F*(const_iterator i1, const_iterator i2, InputIterator first, InputIterator last); // such as replace are called with a type InputIterator that does not qualify as an input iterator, then these functions shall not participate in overload resolution. - A deduction guide for a sequence container shall not participate in overload resolution if it has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter, or if it has an Allocator template parameter and a type that does not qualify as an allocator is deduced for that parameter.

An implementation shall provide
these operations for all container types shown in the “container”
column, and shall implement them so as to take amortized constant
time.

Table 80: Optional sequence container operations [tab:container.seq.opt]

Expression | Return type | Operational semantics | Container | |

a.front() | reference; const_reference for constant a | *a.begin() | basic_string,
array,
deque,
forward_list,
list,
vector | |

a.back() | reference; const_reference for constant a | { auto tmp = a.end(); --tmp; return *tmp; } | basic_string,
array,
deque,
list,
vector | |

a.emplace_front(args) | reference | deque,
forward_list,
list | ||

a.emplace_back(args) | reference | deque,
list,
vector | ||

a.push_front(t) | void | deque,
forward_list,
list | ||

a.push_front(rv) | void | deque,
forward_list,
list | ||

a.push_back(t) | void | basic_string,
deque,
list,
vector | ||

a.push_back(rv) | void | basic_string,
deque,
list,
vector | ||

a.pop_front() | void | deque,
forward_list,
list | ||

a.pop_back() | void | basic_string,
deque,
list,
vector | ||

a[n] | reference; const_reference for constant a | *(a.begin() + n) | basic_string,
array,
deque,
vector | |

a.at(n) | reference; const_reference for constant a | *(a.begin() + n) | basic_string,
array,
deque,
vector |

A *node handle* is an object that accepts ownership of a single element
from an associative container ([associative.reqmts]) or an unordered
associative container ([unord.req]).

It may be used to transfer that
ownership to another container with compatible nodes.

Containers with
compatible nodes have the same node handle type.

Table 81: Container types with compatible nodes [tab:container.node.compat]

map<K, T, C1, A> | map<K, T, C2, A> | |

map<K, T, C1, A> | multimap<K, T, C2, A> | |

set<K, C1, A> | set<K, C2, A> | |

set<K, C1, A> | multiset<K, C2, A> | |

unordered_map<K, T, H1, E1, A> | unordered_map<K, T, H2, E2, A> | |

unordered_map<K, T, H1, E1, A> | unordered_multimap<K, T, H2, E2, A> | |

unordered_set<K, H1, E1, A> | unordered_set<K, H2, E2, A> | |

unordered_set<K, H1, E1, A> | unordered_multiset<K, H2, E2, A> |

If a user-defined specialization of pair exists for
pair<const Key, T> or pair<Key, T>, where Key is the
container's key_type and T is the container's
mapped_type, the behavior of operations involving node handles is
undefined.

template<*unspecified*>
class *node-handle* {
public:
// These type declarations are described in Tables 82 and 83.
using value_type = *see below*; // not present for map containers
using key_type = *see below*; // not present for set containers
using mapped_type = *see below*; // not present for set containers
using allocator_type = *see below*;
private:
using container_node_type = *unspecified*; // *exposition only*
using ator_traits = allocator_traits<allocator_type>; // *exposition only*
typename ator_traits::template
rebind_traits<container_node_type>::pointer ptr_; // *exposition only*
optional<allocator_type> alloc_; // *exposition only*
public:
// [container.node.cons], constructors, copy, and assignment
constexpr *node-handle*() noexcept : ptr_(), alloc_() {}
*node-handle*(*node-handle*&&) noexcept;
*node-handle*& operator=(*node-handle*&&);
// [container.node.dtor], destructor
~*node-handle*();
// [container.node.observers], observers
value_type& value() const; // not present for map containers
key_type& key() const; // not present for set containers
mapped_type& mapped() const; // not present for set containers
allocator_type get_allocator() const;
explicit operator bool() const noexcept;
[[nodiscard]] bool empty() const noexcept;
// [container.node.modifiers], modifiers
void swap(*node-handle*&)
noexcept(ator_traits::propagate_on_container_swap::value ||
ator_traits::is_always_equal::value);
friend void swap(*node-handle*& x, *node-handle*& y) noexcept(noexcept(x.swap(y))) {
x.swap(y);
}
};

*node-handle*(*node-handle*&& nh) noexcept;

*node-handle*& operator=(*node-handle*&& nh);

- If ptr_ != nullptr, destroys the value_type subobject in the container_node_type object pointed to by ptr_ by calling ator_traits::destroy, then deallocates ptr_ by calling ator_traits::template rebind_traits<container_node_type>::deallocate.
- If !alloc_ or ator_traits::propagate_on_container_move_assignment::value is true,

move assigns nh.alloc_ to alloc_.

`~`*node-handle*();

```
value_type& value() const;
```

```
key_type& key() const;
```

```
mapped_type& mapped() const;
```

```
allocator_type get_allocator() const;
```

```
explicit operator bool() const noexcept;
```

```
[[nodiscard]] bool empty() const noexcept;
```

`void swap(`*node-handle*& nh)
noexcept(ator_traits::propagate_on_container_swap::value ||
ator_traits::is_always_equal::value);

The associative containers with unique keys and the unordered containers with unique keys
have a member function insert that returns a nested type insert_return_type.

That return type is a specialization of the template specified in this subclause.

template<class Iterator, class NodeType>
struct *insert-return-type*
{
Iterator position;
bool inserted;
NodeType node;
};

Each associative container is parameterized on
Key
and an ordering relation
Compare
that induces a strict weak ordering on
elements of
Key.

The phrase “equivalence of keys” means the equivalence relation imposed by the
comparison object.

That is, two keys
k1
and
k2
are considered to be equivalent if for the
comparison object
comp,
comp(k1, k2) == false && comp(k2, k1) == false.

For any two keys
k1
and
k2
in the same container, calling
comp(k1, k2)
shall always return the same value.

An associative container supports *unique keys* if it may contain at
most one element for each key.

Otherwise, it supports *equivalent keys*.

The set and map classes support unique keys; the multiset
and multimap classes support equivalent keys.

For multiset and multimap,
insert, emplace, and erase preserve the relative ordering
of equivalent elements.

The associative containers meet all the requirements of
Allocator-aware containers, except that for
map and multimap, the requirements placed on value_type
in Table 78 apply instead to key_type
and mapped_type.

In Table 82,

- X denotes an associative container class,
- a denotes a value of type X,
- b denotes a possibly const value of type X,
- u denotes the name of a variable being declared,
- a_uniq denotes a value of type X when X supports unique keys,
- a_eq denotes a value of type X when X supports multiple keys,
- a_tran denotes a possibly const value of type X when the
*qualified-id*X::key_compare::is_transparent is valid and denotes a type ([temp.deduct]), - i and j meet the
*Cpp17InputIterator*requirements and refer to elements implicitly convertible to value_type, - [i, j) denotes a valid range,
- p denotes a valid constant iterator to a,
- q denotes a valid dereferenceable constant iterator to a,
- r denotes a valid dereferenceable iterator to a,
- [q1, q2) denotes a valid range of constant iterators in a,
- il designates an object of type initializer_list<value_type>,
- t denotes a value of type X::value_type,
- k denotes a value of type X::key_type, and
- c denotes a possibly const value of type X::key_compare;
- kl is a value such that a is partitioned ([alg.sorting]) with respect to c(r, kl), with r the key value of e and e in a;
- ku is a value such that a is partitioned with respect to !c(ku, r);
- ke is a value such that a is partitioned with respect to c(r, ke) and !c(ke, r), with c(r, ke) implying !c(ke, r).
- A denotes the storage allocator used by X, if any, or allocator<X::value_type> otherwise,
- m denotes an allocator of a type convertible to A, and nh denotes a non-const rvalue of type X::node_type.

Table 82: Associative container requirements (in addition to container) [tab:container.assoc.req]

Expression | Return type | Assertion/note | Complexity | |

pre-/post-condition | ||||

Key | compile time | |||

T | compile time | |||

Key | Preconditions: value_type is Cpp17Erasable from X | compile time | ||

X::value_type (map and multimap only) | pair<const Key, T> | Preconditions: value_type is Cpp17Erasable from X | compile time | |

Compare | compile time | |||

a binary predicate type | is the same as key_compare for set and
multiset; is an ordering relation on pairs induced by the
first component (i.e., Key) for map and multimap. | compile time | ||

A specialization of a node-handle
class template, such that the public nested types are
the same types as the corresponding types in X. | see [container.node] | compile time | ||

constant | ||||

X() X u; | constant | |||

X(i,j,c) X u(i,j,c); | in general, where N has the value distance(i, j);
linear if [i, j) is sorted with value_comp() | |||

X(i,j) X u(i,j); | same as above | |||

X(il) | same as X(il.begin(), il.end()) | same as X(il.begin(), il.end()) | ||

X(il,c) | same as X(il.begin(), il.end(), c) | same as X(il.begin(), il.end(), c) | ||

a = il | X& | in general, where N has the value il.size() + a.size();
linear if [il.begin(), il.end()) is sorted with value_comp() | ||

X::key_compare | constant | |||

X::value_compare | Returns: an object of value_compare constructed out of the comparison object | constant | ||

pair<iterator, bool> | Effects: Inserts a value_type object t constructed with
std::forward<Args>(args)... if and only if there is no
element in the container with key equivalent to the key of t.The bool component of the returned
pair is true if and only if the insertion takes place, and the iterator
component of the pair points to the element with key equivalent to the
key of t. | logarithmic | ||

a_eq.emplace(args) | iterator | logarithmic | ||

iterator | logarithmic in general, but amortized constant if the element
is inserted right before p | |||

pair<iterator, bool> | Preconditions: If t is a non-const rvalue, value_type is
Cpp17MoveInsertable into X; otherwise, value_type is
Cpp17CopyInsertable into X.Effects: Inserts t if and only if there is no element in the container
with key equivalent to the key of t.The bool component of
the returned pair is true if and only if the insertion
takes place, and the iterator
component of the pair points to the element with key
equivalent to the key of t. | logarithmic | ||

a_eq.insert(t) | iterator | logarithmic | ||

a.insert(p, t) | iterator | Preconditions: If t is a non-const rvalue, value_type is
Cpp17MoveInsertable into X; otherwise, value_type is
Cpp17CopyInsertable into X.Effects: Inserts t if and only if there is no element with key
equivalent to the key of t in containers with unique keys;
always inserts t in containers with equivalent keys.Always
returns the iterator pointing to the element with key equivalent to
the key of t. | ||

a.insert(i, j) | void | Effects: Inserts each element from the range [i, j) if and only if there
is no element with key equivalent to the key of that element in containers
with unique keys; always inserts that element in containers with equivalent keys. | , where N has the value distance(i, j) | |

a.insert(il) | void | Effects: Equivalent to a.insert(il.begin(), il.end()) | ||

a_uniq.insert(nh) | insert_return_type | Otherwise, inserts the
element owned by nh if and only if there is no element in the
container with a key equivalent to nh.key(). Otherwise if the insertion took place, inserted is true,
position points to the inserted element, and node is empty;
if the insertion failed, inserted is false,
node has the previous value of nh, and position
points to an element with a key equivalent to nh.key(). | logarithmic | |

a_eq.insert(nh) | iterator | logarithmic | ||

a.insert(p, nh) | iterator | Otherwise, inserts the element owned by nh if and only if there
is no element with key equivalent to nh.key() in containers with
unique keys; always inserts the element owned by nh in containers
with equivalent keys. Always returns the iterator pointing to the element
with key equivalent to nh.key(). The element is inserted as close
as possible to the position just prior to p. | logarithmic in general, but amortized constant if the element is inserted right
before p. | |

node_type | ||||

a.extract(q) | node_type | amortized constant | ||

void | Effects: Attempts to extract each element in a2 and insert it into a
using the comparison object of a.In containers with unique keys,
if there is an element in a with key equivalent to the key of an
element from a2, then that element is not extracted from a2. Postconditions: Pointers and references to the transferred elements of a2
refer to those same elements but as members of a.Iterators referring
to the transferred elements will continue to refer to their elements, but
they now behave as iterators into a, not into a2. | |||

size_type | ||||

a.erase(q) | iterator | amortized constant | ||

a.erase(r) | iterator | amortized constant | ||

a.erase( q1, q2) | iterator | |||

void | linear in a.size(). | |||

Returns: An iterator pointing to an element with the key equivalent
to k, or b.end() if such an element is not found. | logarithmic | |||

a_tran. find(ke) | Returns: An iterator pointing to an element with key r such that
!c(r, ke) && !c(ke, r), or a_tran.end() if such an element
is not found. | logarithmic | ||

size_type | ||||

a_tran. count(ke) | size_type | Returns: The number of elements with key r such that
!c(r, ke) && !c(ke, r) | ||

bool | Effects: Equivalent to: return b.find(k) != b.end(); | logarithmic | ||

a_tran. contains(ke) | bool | Effects: Equivalent to: return a_tran.find(ke) != a_tran.end(); | logarithmic | |

Returns: An iterator pointing to the first element with
key not less than k,
or b.end() if such an element is not found. | logarithmic | |||

a_tran. lower_bound(kl) | Returns: An iterator pointing to the first element with
key r such that !c(r, kl),
or a_tran.end() if such an element is not found. | logarithmic | ||

Returns: An iterator pointing to the first element with
key greater than k,
or b.end() if such an element is not found. | logarithmic | |||

a_tran. upper_bound(ku) | Returns: An iterator pointing to the first element with
key r such that c(ku, r),
or a_tran.end() if such an element is not found. | logarithmic | ||

Effects: Equivalent to: return make_pair(b.lower_bound(k), b.upper_bound(k)); | logarithmic | |||

a_tran. equal_range(ke) | Effects: Equivalent to: return make_pair(a_tran.lower_bound(ke), a_tran.upper_bound(ke)); | logarithmic |

The insert and emplace members shall not affect the validity of
iterators and references to the container,
and the erase members shall invalidate only iterators and
references to the erased elements.

The extract members invalidate only iterators to the removed element;
pointers and references to the removed element remain valid.

However, accessing
the element through such pointers and references while the element is owned by
a node_type is undefined behavior.

References and pointers to an element
obtained while it is owned by a node_type are invalidated if the element
is successfully inserted.

The fundamental property of iterators of associative containers is that they iterate through the containers
in the non-descending order of keys where non-descending is defined by the comparison that was used to
construct them.

For any two dereferenceable iterators
i
and
j
such that distance from
i
to
j
is positive, the following condition holds:
value_comp(*j, *i) == false

For associative containers with unique keys the stronger condition holds:
value_comp(*i, *j) != false

When an associative container is constructed by passing a comparison object the
container shall not store a pointer or reference to the passed object,
even if that object is passed by reference.

When an associative container is copied, through either a copy constructor
or an assignment operator,
the target container shall then use the comparison object from the container
being copied,
as if that comparison object had been passed to the target container in
its constructor.

The member function templates
find, count, contains,
lower_bound, upper_bound, and equal_range
shall not participate in overload resolution unless
the *qualified-id* Compare::is_transparent is valid
and denotes a type ([temp.deduct]).

A deduction guide for an associative container shall not participate in overload resolution
if any of the following are true:

- It has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter.
- It has an Allocator template parameter and a type that does not qualify as an allocator is deduced for that parameter.
- It has a Compare template parameter and a type that qualifies as an allocator is deduced for that parameter.

For associative containers, if an exception is thrown by any operation from
within an insert or emplace function inserting a single element, the
insertion has no effect.

Unordered associative containers provide an ability for fast retrieval
of data based on keys.

The worst-case complexity for most operations
is linear, but the average case is much faster.

The library provides
four unordered associative containers: unordered_set,
unordered_map, unordered_multiset, and
unordered_multimap.

Unordered associative containers conform to the requirements for
Containers, except that
the expressions
a == b and a != b have different semantics than for the other
container types.

Each unordered associative container is parameterized by Key,
by a function object type Hash that meets the *Cpp17Hash*
requirements ([hash.requirements]) and acts as a hash function for
argument values of type Key, and by a binary predicate Pred
that induces an equivalence relation on values of type Key.

Additionally, unordered_map and unordered_multimap associate
an arbitrary *mapped type* T with the Key.

The container's object of type Hash — denoted by
hash — is called the *hash function* of the
container.

The container's object of type Pred —
denoted by pred — is called the
*key equality predicate* of the container.

An unordered associative container supports *unique keys* if it
may contain at most one element for each key.

Otherwise, it supports
*equivalent keys*.

In containers that support equivalent keys,
elements with equivalent keys are adjacent to each other
in the iteration order of the container.

Thus, although the absolute order
of elements in an unordered container is not specified, its elements are
grouped into *equivalent-key groups* such that all elements of each
group have equivalent keys.

Mutating operations on unordered containers shall
preserve the relative order of elements within each equivalent-key group
unless otherwise specified.

For unordered containers where the value type is the same as the key
type, both iterator and const_iterator are constant
iterators.

Keys with the same hash code appear in the same
bucket.

The number of buckets is automatically increased as elements
are added to an unordered associative container, so that the average
number of elements per bucket is kept below a bound.

Rehashing
invalidates iterators, changes ordering between elements, and changes
which buckets elements appear in, but does not invalidate pointers or
references to elements.

For unordered_multiset and
unordered_multimap, rehashing preserves the relative ordering of
equivalent elements.

The unordered associative containers meet all the requirements of
Allocator-aware containers, except that for
unordered_map and unordered_multimap, the requirements placed on value_type
in Table 78 apply instead to key_type
and mapped_type.

In Table 83,

- X denotes an unordered associative container class,
- a denotes a value of type X,
- a2 denotes a value of a type with nodes compatible with type X (Table 81),
- b denotes a possibly const value of type X,
- a_uniq denotes a value of type X when X supports unique keys,
- a_eq denotes a value of type X when X supports equivalent keys,
- a_tran denotes a possibly const value of type X
when the
*qualified-id**s*X::key_equal::is_transparent and X::hasher::is_transparent are both valid and denote types ([temp.deduct]), - i and j denote input iterators that refer to value_type,
- [i, j) denotes a valid range,
- p and q2 denote valid constant iterators to a,
- q and q1 denote valid dereferenceable constant iterators to a,
- r denotes a valid dereferenceable iterator to a,
- [q1, q2) denotes a valid range in a,
- il denotes a value of type initializer_list<value_type>,
- t denotes a value of type X::value_type,
- k denotes a value of type key_type,
- hf denotes a possibly const value of type hasher,
- eq denotes a possibly const value of type key_equal,
- ke is a value such that
- eq(r1, ke) == eq(ke, r1)
- hf(r1) == hf(ke) if eq(r1, ke) is true, and
- (eq(r1, ke) && eq(r1, r2)) == eq(r2, ke)

- n denotes a value of type size_type,
- z denotes a value of type float, and
- nh denotes a non-const rvalue of type X::node_type.

Table 83: Unordered associative container requirements (in addition to container) [tab:container.hash.req]

Expression | Return type | Assertion/note | Complexity | |

pre-/post-condition | ||||

Key | compile time | |||

T | compile time | |||

Key | Preconditions: value_type is Cpp17Erasable from X | compile time | ||

X::value_type (unordered_map and unordered_multimap only) | pair<const Key, T> | Preconditions: value_type is Cpp17Erasable from X | compile time | |

Hash | Preconditions: Hash is a unary function object type such that the expression
hf(k) has type size_t. | compile time | ||

Pred | compile time | |||

An iterator type whose category, value type,
difference type, and pointer and reference types are the same as
X::iterator's. | A local_iterator object may be used to iterate through a
single bucket, but may not be used to iterate across
buckets. | compile time | ||

An iterator type whose category, value type,
difference type, and pointer and reference types are the same as
X::const_iterator's. | A const_local_iterator object may be used to iterate through a
single bucket, but may not be used to iterate across
buckets. | compile time | ||

a specialization of a node-handle
class template, such that the public nested types are
the same types as the corresponding types in X. | see [container.node] | compile time | ||

X | Effects: Constructs an empty container with at least n buckets,
using hf as the hash function and eq as the key
equality predicate. | |||

X(n, hf) X a(n, hf); | X | |||

X(n) X a(n); | X | |||

X() X a; | X | constant | ||

X(i, j, n, hf, eq) X a(i, j, n, hf, eq); | X | Average case (N is distance(i, j)), worst case
| ||

X(i, j, n, hf) X a(i, j, n, hf); | X | Effects: Constructs an empty container with at least n buckets,
using hf as the hash function and key_equal() as the key
equality predicate, and inserts elements from [i, j) into it. | Average case (N is distance(i, j)), worst case
| |

X(i, j, n) X a(i, j, n); | X | Effects: Constructs an empty container with at least n buckets,
using hasher() as the hash function and key_equal()
as the key equality predicate, and inserts elements from [i, j)
into it. | Average case (N is distance(i, j)), worst case
| |

X(i, j) X a(i, j); | X | Effects: Constructs an empty container with an unspecified number of
buckets, using hasher() as the hash function and
key_equal() as the key equality predicate, and inserts elements
from [i, j) into it. | Average case (N is distance(i, j)), worst case
| |

X(il) | X | Same as X(il.begin(), il.end()). | ||

X(il, n) | X | Same as X(il.begin(), il.end(), n). | ||

X(il, n, hf) | X | Same as X(il.begin(), il.end(), n, hf). | ||

X(il, n, hf, eq) | X | Same as X(il.begin(), il.end(), n, hf, eq). | ||

X(b) X a(b); | X | Average case linear in b.size(), worst case quadratic. | ||

a = b | X& | Average case linear in b.size(), worst case quadratic. | ||

a = il | X& | Same as a = X(il). | ||

hasher | constant | |||

key_equal | constant | |||

pair<iterator, bool> | Effects: Inserts a value_type object t constructed with
std::forward<Args>(args)... if and only if there is no
element in the container with key equivalent to the key of t.The bool component of the returned
pair is true if and only if the insertion takes place, and the iterator
component of the pair points to the element with key equivalent to the
key of t. | |||

a_eq.emplace(args) | iterator | |||

iterator | ||||

pair<iterator, bool> | Preconditions: If t is a non-const rvalue, value_type is
Cpp17MoveInsertable into X; otherwise, value_type is
Cpp17CopyInsertable into X.Effects: Inserts t if and only if there is no element in the container
with key equivalent to the key of t.The bool
component of the returned pair indicates whether the insertion
takes place, and the iterator component points to the element
with key equivalent to the key of t. | |||

a_eq.insert(t) | iterator | |||

a.insert(p, t) | iterator | Preconditions: If t is a non-const rvalue, value_type is
Cpp17MoveInsertable into X; otherwise, value_type is
Cpp17CopyInsertable into X.Return value is an iterator pointing
to the element with the key equivalent to that of t. The
iterator p is a hint pointing to where the search should
start. Implementations are permitted to ignore the hint. | ||

a.insert(i, j) | void | |||

a.insert(il) | void | Same as a.insert(il.begin(), il.end()). | ||

a_uniq. insert(nh) | insert_return_type | Otherwise, inserts the
element owned by nh if and only if there is no element in the
container with a key equivalent to nh.key(). Otherwise if the insertion took place, inserted is true,
position points to the inserted element, and node is empty;
if the insertion failed, inserted is false,
node has the previous value of nh, and position
points to an element with a key equivalent to nh.key(). | ||

a_eq. insert(nh) | iterator | |||

a.insert(q, nh) | iterator | Otherwise, inserts the element owned by nh if and only if there
is no element with key equivalent to nh.key() in containers with
unique keys; always inserts the element owned by nh in containers
with equivalent keys. Always returns the iterator pointing to the element
with key equivalent to nh.key(). The iterator q is a hint
pointing to where the search should start. Implementations are permitted
to ignore the hint. | ||

node_type | ||||

a.extract(q) | node_type | |||

void | Attempts to extract each element in a2 and insert it into a using the hash function and key equality predicate of a. In containers with unique keys, if there is an element in a with
key equivalent to the key of an element from a2, then that
element is not extracted from a2. Postconditions: Pointers and references to the transferred elements of a2
refer to those same elements but as members of a.Iterators referring
to the transferred elements and all iterators referring to a will
be invalidated, but iterators to elements remaining in a2 will
remain valid. | |||

size_type | ||||

a.erase(q) | iterator | |||

a.erase(r) | iterator | |||

a.erase(q1, q2) | iterator | |||

void | Effects: Erases all elements in the container.Postconditions: a.empty() is true | Linear in a.size(). | ||

Returns: An iterator pointing to an element with key equivalent to
k, or b.end() if no such element exists. | ||||

a_tran.find(ke) | Returns: An iterator pointing to an element with key equivalent to
ke, or a_tran.end() if no such element exists. | |||

size_type | ||||

a_tran.count(ke) | size_type | |||

bool | Effects: Equivalent to b.find(k) != b.end() | |||

a_tran.contains(ke) | bool | Effects: Equivalent to a_tran.find(ke) != a_tran.end() | ||

a_tran.equal_range(ke) | ||||

size_type | Constant | |||

size_type | Constant | |||

size_type | Constant | |||

size_type | ||||

Constant | ||||

Constant | ||||

const_local_iterator | Constant | |||

const_local_iterator | Constant | |||

float | Returns: The average number of elements per bucket. | Constant | ||

float | Constant | |||

a.max_load_factor(z) | void | Constant | ||

void | Average case linear in a.size(), worst case quadratic. | |||

void | Average case linear in a.size(), worst case quadratic. |

Two unordered containers a and b compare equal if
a.size() == b.size() and, for every equivalent-key group
[Ea1, Ea2) obtained from a.equal_range(Ea1), there exists an
equivalent-key group [Eb1, Eb2) obtained from b.equal_range(Ea1),
such that
is_permutation(Ea1, Ea2, Eb1, Eb2) returns true.

For
unordered_set and unordered_map, the complexity of
operator== (i.e., the number of calls to the == operator
of the value_type, to the predicate returned by key_eq(),
and to the hasher returned by hash_function()) is proportional to
N in the average case and to in the worst case, where N is
a.size().

For unordered_multiset and unordered_multimap,
the complexity of operator== is proportional to
in the average case and to in the worst case, where N is a.size(),
and is the size of the equivalent-key group in a.

However, if the respective elements of each corresponding pair of
equivalent-key groups and are arranged in the same order
(as is commonly the case, e.g., if a and b are unmodified copies
of the same container), then the average-case complexity for
unordered_multiset and unordered_multimap becomes
proportional to N (but worst-case complexity remains , e.g., for
a pathologically bad hash function).

The insert and emplace members shall not affect the validity of references to
container elements, but may invalidate all iterators to the
container.

The erase members shall invalidate only iterators and
references to the erased elements, and preserve the relative order of the
elements that are not erased.

The insert and emplace members shall not affect the validity of iterators if
(N+n) <= z * B, where N is the number of elements in
the container prior to the insert operation, n is the
number of elements inserted, B is the container's bucket count, and
z is the container's maximum load factor.

The extract members invalidate only iterators to the removed element,
and preserve the relative order of the elements that are not erased; pointers
and references to the removed element remain valid.

However, accessing the
element through such pointers and references while the element is owned by a
node_type is undefined behavior.

References and pointers to an element
obtained while it is owned by a node_type are invalidated if the
element is successfully inserted.

The member function templates
find, count, equal_range, and contains
shall not participate in overload resolution unless
the *qualified-id**s*
Pred::is_transparent and
Hash::is_transparent
are both valid and denote types ([temp.deduct]).

A deduction guide for an unordered associative container shall not participate in overload resolution
if any of the following are true:

- It has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter.
- It has an Allocator template parameter and a type that does not qualify as an allocator is deduced for that parameter.
- It has a Hash template parameter and an integral type or a type that qualifies as an allocator is deduced for that parameter.
- It has a Pred template parameter and a type that qualifies as an allocator is deduced for that parameter.

For unordered associative containers, if an exception is thrown by any
operation other than the container's hash function from within an
insert or emplace function inserting a single element,
the insertion has no effect.

For unordered associative containers, no swap function throws
an exception unless that exception is thrown by the swap of the container's
Hash or Pred object (if any).

#include <compare> // see [compare.syn]
#include <initializer_list> // see [initializer.list.syn]
namespace std {
// [array], class template array
template<class T, size_t N> struct array;
template<class T, size_t N>
constexpr bool operator==(const array<T, N>& x, const array<T, N>& y);
template<class T, size_t N>
constexpr *synth-three-way-result*<T>
operator<=>(const array<T, N>& x, const array<T, N>& y);
// [array.special], specialized algorithms
template<class T, size_t N>
constexpr void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));
// [array.creation], array creation functions
template<class T, size_t N>
constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]);
template<class T, size_t N>
constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]);
// [array.tuple], tuple interface
template<class T> struct tuple_size;
template<size_t I, class T> struct tuple_element;
template<class T, size_t N>
struct tuple_size<array<T, N>>;
template<size_t I, class T, size_t N>
struct tuple_element<I, array<T, N>>;
template<size_t I, class T, size_t N>
constexpr T& get(array<T, N>&) noexcept;
template<size_t I, class T, size_t N>
constexpr T&& get(array<T, N>&&) noexcept;
template<size_t I, class T, size_t N>
constexpr const T& get(const array<T, N>&) noexcept;
template<size_t I, class T, size_t N>
constexpr const T&& get(const array<T, N>&&) noexcept;
}

#include <compare> // see [compare.syn]
#include <initializer_list> // see [initializer.list.syn]
namespace std {
// [deque], class template deque
template<class T, class Allocator = allocator<T>> class deque;
template<class T, class Allocator>
bool operator==(const deque<T, Allocator>& x, const deque<T, Allocator>& y);
template<class T, class Allocator>
*synth-three-way-result*<T> operator<=>(const deque<T, Allocator>& x,
const deque<T, Allocator>& y);
template<class T, class Allocator>
void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template<class T, class Allocator, class U>
typename deque<T, Allocator>::size_type
erase(deque<T, Allocator>& c, const U& value);
template<class T, class Allocator, class Predicate>
typename deque<T, Allocator>::size_type
erase_if(deque<T, Allocator>& c, Predicate pred);
namespace pmr {
template<class T>
using deque = std::deque<T, polymorphic_allocator<T>>;
}
}

#include <compare> // see [compare.syn]
#include <initializer_list> // see [initializer.list.syn]
namespace std {
// [forwardlist], class template forward_list
template<class T, class Allocator = allocator<T>> class forward_list;
template<class T, class Allocator>
bool operator==(const forward_list<T, Allocator>& x, const forward_list<T, Allocator>& y);
template<class T, class Allocator>
*synth-three-way-result*<T> operator<=>(const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y);
template<class T, class Allocator>
void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template<class T, class Allocator, class U>
typename forward_list<T, Allocator>::size_type
erase(forward_list<T, Allocator>& c, const U& value);
template<class T, class Allocator, class Predicate>
typename forward_list<T, Allocator>::size_type
erase_if(forward_list<T, Allocator>& c, Predicate pred);
namespace pmr {
template<class T>
using forward_list = std::forward_list<T, polymorphic_allocator<T>>;
}
}

#include <compare> // see [compare.syn]
#include <initializer_list> // see [initializer.list.syn]
namespace std {
// [list], class template list
template<class T, class Allocator = allocator<T>> class list;
template<class T, class Allocator>
bool operator==(const list<T, Allocator>& x, const list<T, Allocator>& y);
template<class T, class Allocator>
*synth-three-way-result*<T> operator<=>(const list<T, Allocator>& x,
const list<T, Allocator>& y);
template<class T, class Allocator>
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template<class T, class Allocator, class U>
typename list<T, Allocator>::size_type
erase(list<T, Allocator>& c, const U& value);
template<class T, class Allocator, class Predicate>
typename list<T, Allocator>::size_type
erase_if(list<T, Allocator>& c, Predicate pred);
namespace pmr {
template<class T>
using list = std::list<T, polymorphic_allocator<T>>;
}
}

#include <compare> // see [compare.syn]
#include <initializer_list> // see [initializer.list.syn]
namespace std {
// [vector], class template vector
template<class T, class Allocator = allocator<T>> class vector;
template<class T, class Allocator>
constexpr bool operator==(const vector<T, Allocator>& x, const vector<T, Allocator>& y);
template<class T, class Allocator>
constexpr *synth-three-way-result*<T> operator<=>(const vector<T, Allocator>& x,
const vector<T, Allocator>& y);
template<class T, class Allocator>
constexpr void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template<class T, class Allocator, class U>
constexpr typename vector<T, Allocator>::size_type
erase(vector<T, Allocator>& c, const U& value);
template<class T, class Allocator, class Predicate>
constexpr typename vector<T, Allocator>::size_type
erase_if(vector<T, Allocator>& c, Predicate pred);
// [vector.bool], class vector<bool>
template<class Allocator> class vector<bool, Allocator>;
// hash support
template<class T> struct hash;
template<class Allocator> struct hash<vector<bool, Allocator>>;
namespace pmr {
template<class T>
using vector = std::vector<T, polymorphic_allocator<T>>;
}
}

An array meets all of the requirements of a container and
of a reversible container ([container.requirements]), except that a default
constructed array object is not empty and that swap does not have constant
complexity.

Descriptions are provided here
only for operations on array that are not described in
one of these tables and
for operations where there is additional semantic information.

Two values a1 and a2 of type array<T, N>
are template-argument-equivalent if and only if
each pair of corresponding elements in a1 and a2
are template-argument-equivalent.

namespace std {
template<class T, size_t N>
struct array {
// types
using value_type = T;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using size_type = size_t;
using difference_type = ptrdiff_t;
using iterator = *implementation-defined*; // see [container.requirements]
using const_iterator = *implementation-defined*; // see [container.requirements]
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// no explicit construct/copy/destroy for aggregate type
constexpr void fill(const T& u);
constexpr void swap(array&) noexcept(is_nothrow_swappable_v<T>);
// iterators
constexpr iterator begin() noexcept;
constexpr const_iterator begin() const noexcept;
constexpr iterator end() noexcept;
constexpr const_iterator end() const noexcept;
constexpr reverse_iterator rbegin() noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr reverse_iterator rend() noexcept;
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// capacity
[[nodiscard]] constexpr bool empty() const noexcept;
constexpr size_type size() const noexcept;
constexpr size_type max_size() const noexcept;
// element access
constexpr reference operator[](size_type n);
constexpr const_reference operator[](size_type n) const;
constexpr reference at(size_type n);
constexpr const_reference at(size_type n) const;
constexpr reference front();
constexpr const_reference front() const;
constexpr reference back();
constexpr const_reference back() const;
constexpr T * data() noexcept;
constexpr const T * data() const noexcept;
};
template<class T, class... U>
array(T, U...) -> array<T, 1 + sizeof...(U)>;
}

Class array relies on the implicitly-declared special
member functions ([class.default.ctor], [class.dtor], and [class.copy.ctor]) to
conform to the container requirements table in [container.requirements].

In addition to the requirements specified in the container requirements table,
the implicit move constructor and move assignment operator for array
require that T be *Cpp17MoveConstructible* or *Cpp17MoveAssignable*,
respectively.

```
template<class T, class... U>
array(T, U...) -> array<T, 1 + sizeof...(U)>;
```

```
constexpr size_type size() const noexcept;
```

```
constexpr T* data() noexcept;
constexpr const T* data() const noexcept;
```

```
constexpr void fill(const T& u);
```

```
constexpr void swap(array& y) noexcept(is_nothrow_swappable_v<T>);
```

```
template<class T, size_t N>
constexpr void swap(array<T, N>& x, array<T, N>& y) noexcept(noexcept(x.swap(y)));
```

```
template<class T, size_t N>
constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]);
```

```
template<class T, size_t N>
constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]);
```

```
template<class T, size_t N>
struct tuple_size<array<T, N>> : integral_constant<size_t, N> { };
```

```
template<size_t I, class T, size_t N>
struct tuple_element<I, array<T, N>> {
using type = T;
};
```

```
template<size_t I, class T, size_t N>
constexpr T& get(array<T, N>& a) noexcept;
template<size_t I, class T, size_t N>
constexpr T&& get(array<T, N>&& a) noexcept;
template<size_t I, class T, size_t N>
constexpr const T& get(const array<T, N>& a) noexcept;
template<size_t I, class T, size_t N>
constexpr const T&& get(const array<T, N>&& a) noexcept;
```

A
deque
meets all of the requirements of a container, of a reversible container
(given in tables in [container.requirements]), of a sequence container,
including the optional sequence container requirements ([sequence.reqmts]), and of an allocator-aware container (Table 78).

Descriptions are provided here only for operations on
deque
that are not described in one of these tables
or for operations where there is additional semantic information.

namespace std {
template<class T, class Allocator = allocator<T>>
class deque {
public:
// types
using value_type = T;
using allocator_type = Allocator;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
using reference = value_type&;
using const_reference = const value_type&;
using size_type = *implementation-defined*; // see [container.requirements]
using difference_type = *implementation-defined*; // see [container.requirements]
using iterator = *implementation-defined*; // see [container.requirements]
using const_iterator = *implementation-defined*; // see [container.requirements]
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// [deque.cons], construct/copy/destroy
deque() : deque(Allocator()) { }
explicit deque(const Allocator&);
explicit deque(size_type n, const Allocator& = Allocator());
deque(size_type n, const T& value, const Allocator& = Allocator());
template<class InputIterator>
deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
deque(const deque& x);
deque(deque&&);
deque(const deque&, const Allocator&);
deque(deque&&, const Allocator&);
deque(initializer_list<T>, const Allocator& = Allocator());
~deque();
deque& operator=(const deque& x);
deque& operator=(deque&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value);
deque& operator=(initializer_list<T>);
template<class InputIterator>
void assign(InputIterator first, InputIterator last);
void assign(size_type n, const T& t);
void assign(initializer_list<T>);
allocator_type get_allocator() const noexcept;
// iterators
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// [deque.capacity], capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
void resize(size_type sz);
void resize(size_type sz, const T& c);
void shrink_to_fit();
// element access
reference operator[](size_type n);
const_reference operator[](size_type n) const;
reference at(size_type n);
const_reference at(size_type n) const;
reference front();
const_reference front() const;
reference back();
const_reference back() const;
// [deque.modifiers], modifiers
template<class... Args> reference emplace_front(Args&&... args);
template<class... Args> reference emplace_back(Args&&... args);
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
void push_front(const T& x);
void push_front(T&& x);
void push_back(const T& x);
void push_back(T&& x);
iterator insert(const_iterator position, const T& x);
iterator insert(const_iterator position, T&& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<T>);
void pop_front();
void pop_back();
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void swap(deque&)
noexcept(allocator_traits<Allocator>::is_always_equal::value);
void clear() noexcept;
};
template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>>
deque(InputIterator, InputIterator, Allocator = Allocator())
-> deque<*iter-value-type*<InputIterator>, Allocator>;
}

```
explicit deque(const Allocator&);
```

```
explicit deque(size_type n, const Allocator& = Allocator());
```

```
deque(size_type n, const T& value, const Allocator& = Allocator());
```

```
template<class InputIterator>
deque(InputIterator first, InputIterator last, const Allocator& = Allocator());
```

```
void resize(size_type sz);
```

```
void resize(size_type sz, const T& c);
```

```
void shrink_to_fit();
```

```
iterator insert(const_iterator position, const T& x);
iterator insert(const_iterator position, T&& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert(const_iterator position,
InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<T>);
template<class... Args> reference emplace_front(Args&&... args);
template<class... Args> reference emplace_back(Args&&... args);
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
void push_front(const T& x);
void push_front(T&& x);
void push_back(const T& x);
void push_back(T&& x);
```

If an exception is thrown while inserting a single element at either end,
there are no effects.

Otherwise, if an exception is thrown by the move constructor of a
non-*Cpp17CopyInsertable*
T, the effects are unspecified.

```
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void pop_front();
void pop_back();
```

An erase operation that erases the first
element of a deque but not the last element invalidates only iterators
and references to the erased elements.

An erase operation
that erases neither the first element nor the last element of a deque invalidates the past-the-end
iterator and all iterators and references to all the elements of the deque.

```
template<class T, class Allocator, class U>
typename deque<T, Allocator>::size_type
erase(deque<T, Allocator>& c, const U& value);
```

```
template<class T, class Allocator, class Predicate>
typename deque<T, Allocator>::size_type
erase_if(deque<T, Allocator>& c, Predicate pred);
```

A forward_list meets all of the requirements of a container
(Table 75), except that the size()
member function is not provided and operator== has linear complexity.

In addition, a forward_list
provides the assign member functions
(Table 79) and several of the optional
container requirements (Table 80).

Descriptions are provided here only for operations on
forward_list that are not described in that table or for operations where there
is additional semantic information.

namespace std {
template<class T, class Allocator = allocator<T>>
class forward_list {
public:
// types
using value_type = T;
using allocator_type = Allocator;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
using reference = value_type&;
using const_reference = const value_type&;
using size_type = *implementation-defined*; // see [container.requirements]
using difference_type = *implementation-defined*; // see [container.requirements]
using iterator = *implementation-defined*; // see [container.requirements]
using const_iterator = *implementation-defined*; // see [container.requirements]
// [forwardlist.cons], construct/copy/destroy
forward_list() : forward_list(Allocator()) { }
explicit forward_list(const Allocator&);
explicit forward_list(size_type n, const Allocator& = Allocator());
forward_list(size_type n, const T& value, const Allocator& = Allocator());
template<class InputIterator>
forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
forward_list(const forward_list& x);
forward_list(forward_list&& x);
forward_list(const forward_list& x, const Allocator&);
forward_list(forward_list&& x, const Allocator&);
forward_list(initializer_list<T>, const Allocator& = Allocator());
~forward_list();
forward_list& operator=(const forward_list& x);
forward_list& operator=(forward_list&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value);
forward_list& operator=(initializer_list<T>);
template<class InputIterator>
void assign(InputIterator first, InputIterator last);
void assign(size_type n, const T& t);
void assign(initializer_list<T>);
allocator_type get_allocator() const noexcept;
// [forwardlist.iter], iterators
iterator before_begin() noexcept;
const_iterator before_begin() const noexcept;
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cbefore_begin() const noexcept;
const_iterator cend() const noexcept;
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type max_size() const noexcept;
// [forwardlist.access], element access
reference front();
const_reference front() const;
// [forwardlist.modifiers], modifiers
template<class... Args> reference emplace_front(Args&&... args);
void push_front(const T& x);
void push_front(T&& x);
void pop_front();
template<class... Args> iterator emplace_after(const_iterator position, Args&&... args);
iterator insert_after(const_iterator position, const T& x);
iterator insert_after(const_iterator position, T&& x);
iterator insert_after(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
iterator insert_after(const_iterator position, initializer_list<T> il);
iterator erase_after(const_iterator position);
iterator erase_after(const_iterator position, const_iterator last);
void swap(forward_list&)
noexcept(allocator_traits<Allocator>::is_always_equal::value);
void resize(size_type sz);
void resize(size_type sz, const value_type& c);
void clear() noexcept;
// [forwardlist.ops], forward_list operations
void splice_after(const_iterator position, forward_list& x);
void splice_after(const_iterator position, forward_list&& x);
void splice_after(const_iterator position, forward_list& x, const_iterator i);
void splice_after(const_iterator position, forward_list&& x, const_iterator i);
void splice_after(const_iterator position, forward_list& x,
const_iterator first, const_iterator last);
void splice_after(const_iterator position, forward_list&& x,
const_iterator first, const_iterator last);
size_type remove(const T& value);
template<class Predicate> size_type remove_if(Predicate pred);
size_type unique();
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
void merge(forward_list& x);
void merge(forward_list&& x);
template<class Compare> void merge(forward_list& x, Compare comp);
template<class Compare> void merge(forward_list&& x, Compare comp);
void sort();
template<class Compare> void sort(Compare comp);
void reverse() noexcept;
};
template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>>
forward_list(InputIterator, InputIterator, Allocator = Allocator())
-> forward_list<*iter-value-type*<InputIterator>, Allocator>;
}

An incomplete type T may be used when instantiating forward_list
if the allocator meets the
allocator completeness requirements.

T shall be complete before any member of the resulting specialization
of forward_list is referenced.

```
explicit forward_list(const Allocator&);
```

```
explicit forward_list(size_type n, const Allocator& = Allocator());
```

```
forward_list(size_type n, const T& value, const Allocator& = Allocator());
```

```
template<class InputIterator>
forward_list(InputIterator first, InputIterator last, const Allocator& = Allocator());
```

```
iterator before_begin() noexcept;
const_iterator before_begin() const noexcept;
const_iterator cbefore_begin() const noexcept;
```

```
reference front();
const_reference front() const;
```

None of the overloads of insert_after shall affect the validity of iterators and
references, and erase_after shall invalidate only iterators and references to
the erased elements.

If an exception is thrown during insert_after there shall
be no effect.

Inserting n elements into a forward_list is linear in
n, and the number of calls to the copy or move constructor of T is
exactly equal to n.

Erasing n elements from a forward_list is
linear in n and the number of calls to the destructor of type T is
exactly equal to n.

```
template<class... Args> reference emplace_front(Args&&... args);
```

```
void push_front(const T& x);
void push_front(T&& x);
```

```
void pop_front();
```

```
iterator insert_after(const_iterator position, const T& x);
iterator insert_after(const_iterator position, T&& x);
```

```
iterator insert_after(const_iterator position, size_type n, const T& x);
```

```
template<class InputIterator>
iterator insert_after(const_iterator position, InputIterator first, InputIterator last);
```

```
iterator insert_after(const_iterator position, initializer_list<T> il);
```

```
template<class... Args>
iterator emplace_after(const_iterator position, Args&&... args);
```

```
iterator erase_after(const_iterator position);
```

```
iterator erase_after(const_iterator position, const_iterator last);
```

```
void resize(size_type sz);
```

```
void resize(size_type sz, const value_type& c);
```

```
void clear() noexcept;
```

In this subclause,
arguments for a template parameter
named Predicate or BinaryPredicate
shall meet the corresponding requirements in [algorithms.requirements].

```
void splice_after(const_iterator position, forward_list& x);
void splice_after(const_iterator position, forward_list&& x);
```

```
void splice_after(const_iterator position, forward_list& x, const_iterator i);
void splice_after(const_iterator position, forward_list&& x, const_iterator i);
```

Iterators to *++i continue to refer to
the same element, but now behave as iterators into *this, not into x.

```
void splice_after(const_iterator position, forward_list& x,
const_iterator first, const_iterator last);
void splice_after(const_iterator position, forward_list&& x,
const_iterator first, const_iterator last);
```

Pointers and references to the moved elements of
x now refer to those same elements but as members of *this.

Iterators
referring to the moved elements will continue to refer to their elements, but they now
behave as iterators into *this, not into x.

```
size_type remove(const T& value);
template<class Predicate> size_type remove_if(Predicate pred);
```

```
size_type unique();
template<class BinaryPredicate> size_type unique(BinaryPredicate pred);
```

Invalidates only the iterators and references to the erased elements.

```
void merge(forward_list& x);
void merge(forward_list&& x);
template<class Compare> void merge(forward_list& x, Compare comp);
template<class Compare> void merge(forward_list&& x, Compare comp);
```

x is empty after the merge.

If an
exception is thrown other than by a comparison there are no effects.

Pointers and references to the moved elements of x now refer to those same elements
but as members of *this.

Iterators referring to the moved elements will continue to
refer to their elements, but they now behave as iterators into *this, not into
x.

```
void sort();
template<class Compare> void sort(Compare comp);
```

```
void reverse() noexcept;
```

```
template<class T, class Allocator, class U>
typename forward_list<T, Allocator>::size_type
erase(forward_list<T, Allocator>& c, const U& value);
```

```
template<class T, class Allocator, class Predicate>
typename forward_list<T, Allocator>::size_type
erase_if(forward_list<T, Allocator>& c, Predicate pred);
```

A
list
is a sequence container that supports
bidirectional iterators and allows constant time insert and erase
operations anywhere within the sequence, with storage management handled
automatically.

A list meets all of the requirements of a container, of
a reversible container (given in two tables in
[container.requirements]), of a sequence container,
including most of the optional sequence container
requirements ([sequence.reqmts]), and of an allocator-aware container
(Table 78).

Descriptions are provided here only for operations on
list
that are not described in one of these tables
or for operations where there is additional semantic information.

namespace std {
template<class T, class Allocator = allocator<T>>
class list {
public:
// types
using value_type = T;
using allocator_type = Allocator;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
using reference = value_type&;
using const_reference = const value_type&;
using size_type = *implementation-defined*; // see [container.requirements]
using difference_type = *implementation-defined*; // see [container.requirements]
using iterator = *implementation-defined*; // see [container.requirements]
using const_iterator = *implementation-defined*; // see [container.requirements]
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// [list.cons], construct/copy/destroy
list() : list(Allocator()) { }
explicit list(const Allocator&);
explicit list(size_type n, const Allocator& = Allocator());
list(size_type n, const T& value, const Allocator& = Allocator());
template<class InputIterator>
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
list(const list& x);
list(list&& x);
list(const list&, const Allocator&);
list(list&&, const Allocator&);
list(initializer_list<T>, const Allocator& = Allocator());
~list();
list& operator=(const list& x);
list& operator=(list&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value);
list& operator=(initializer_list<T>);
template<class InputIterator>
void assign(InputIterator first, InputIterator last);
void assign(size_type n, const T& t);
void assign(initializer_list<T>);
allocator_type get_allocator() const noexcept;
// iterators
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// [list.capacity], capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
void resize(size_type sz);
void resize(size_type sz, const T& c);
// element access
reference front();
const_reference front() const;
reference back();
const_reference back() const;
// [list.modifiers], modifiers
template<class... Args> reference emplace_front(Args&&... args);
template<class... Args> reference emplace_back(Args&&... args);
void push_front(const T& x);
void push_front(T&& x);
void pop_front();
void push_back(const T& x);
void push_back(T&& x);
void pop_back();
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
iterator insert(const_iterator position, const T& x);
iterator insert(const_iterator position, T&& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<T> il);
iterator erase(const_iterator position);
iterator erase(const_iterator position, const_iterator last);
void swap(list&) noexcept(allocator_traits<Allocator>::is_always_equal::value);
void clear() noexcept;
// [list.ops], list operations
void splice(const_iterator position, list& x);
void splice(const_iterator position, list&& x);
void splice(const_iterator position, list& x, const_iterator i);
void splice(const_iterator position, list&& x, const_iterator i);
void splice(const_iterator position, list& x, const_iterator first, const_iterator last);
void splice(const_iterator position, list&& x, const_iterator first, const_iterator last);
size_type remove(const T& value);
template<class Predicate> size_type remove_if(Predicate pred);
size_type unique();
template<class BinaryPredicate>
size_type unique(BinaryPredicate binary_pred);
void merge(list& x);
void merge(list&& x);
template<class Compare> void merge(list& x, Compare comp);
template<class Compare> void merge(list&& x, Compare comp);
void sort();
template<class Compare> void sort(Compare comp);
void reverse() noexcept;
};
template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>>
list(InputIterator, InputIterator, Allocator = Allocator())
-> list<*iter-value-type*<InputIterator>, Allocator>;
}

An incomplete type T may be used when instantiating list
if the allocator meets the
allocator completeness requirements.

```
explicit list(const Allocator&);
```

```
explicit list(size_type n, const Allocator& = Allocator());
```

```
list(size_type n, const T& value, const Allocator& = Allocator());
```

```
template<class InputIterator>
list(InputIterator first, InputIterator last, const Allocator& = Allocator());
```

```
iterator insert(const_iterator position, const T& x);
iterator insert(const_iterator position, T&& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert(const_iterator position, InputIterator first,
InputIterator last);
iterator insert(const_iterator position, initializer_list<T>);
template<class... Args> reference emplace_front(Args&&... args);
template<class... Args> reference emplace_back(Args&&... args);
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
void push_front(const T& x);
void push_front(T&& x);
void push_back(const T& x);
void push_back(T&& x);
```

Insertion of multiple elements into a list is linear in the
number of elements inserted, and the number of calls to the copy
constructor or move constructor of T is exactly equal
to the number of elements inserted.

```
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void pop_front();
void pop_back();
void clear() noexcept;
```

Since lists allow fast insertion and erasing from the middle of a list, certain
operations are provided specifically for them.222

In this subclause,
arguments for a template parameter
named Predicate or BinaryPredicate
shall meet the corresponding requirements in [algorithms.requirements].

```
void splice(const_iterator position, list& x);
void splice(const_iterator position, list&& x);
```

```
void splice(const_iterator position, list& x, const_iterator i);
void splice(const_iterator position, list&& x, const_iterator i);
```

```
void splice(const_iterator position, list& x, const_iterator first,
const_iterator last);
void splice(const_iterator position, list&& x, const_iterator first,
const_iterator last);
```

Pointers and references to the moved elements of
x
now refer to those same elements but as members of
*this.

Iterators referring to the moved elements will continue to refer to their
elements, but they now behave as iterators into
*this,
not into
x.

```
size_type remove(const T& value);
template<class Predicate> size_type remove_if(Predicate pred);
```

```
size_type unique();
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
```

Invalidates only the iterators and references to the erased elements.

```
void merge(list& x);
void merge(list&& x);
template<class Compare> void merge(list& x, Compare comp);
template<class Compare> void merge(list&& x, Compare comp);
```

The result is a range in which the elements
will be sorted in non-decreasing order according to the ordering defined by comp; that
is, for every iterator i, in the range other than the first, the condition
comp(*i, *(i - 1)) will be false.

```
void reverse() noexcept;
```

```
void sort();
template<class Compare> void sort(Compare comp);
```

222)222)

As specified
in [allocator.requirements], the requirements in this Clause apply only to
lists whose allocators compare equal.

```
template<class T, class Allocator, class U>
typename list<T, Allocator>::size_type
erase(list<T, Allocator>& c, const U& value);
```

```
template<class T, class Allocator, class Predicate>
typename list<T, Allocator>::size_type
erase_if(list<T, Allocator>& c, Predicate pred);
```

A vector meets all of the requirements of a container and of a
reversible container (given in two tables in [container.requirements]), of a
sequence container, including most of the optional sequence container
requirements ([sequence.reqmts]), of an allocator-aware container
(Table 78),
and, for an element type other than bool,
of a contiguous container.

The exceptions are the
push_front, pop_front, and emplace_front member functions, which are not
provided.

Descriptions are provided here only for operations on vector
that are not described in one of these tables or for operations where there is
additional semantic information.

The types iterator and const_iterator meet
the constexpr iterator requirements ([iterator.requirements.general]).

namespace std {
template<class T, class Allocator = allocator<T>>
class vector {
public:
// types
using value_type = T;
using allocator_type = Allocator;
using pointer = typename allocator_traits<Allocator>::pointer;
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
using reference = value_type&;
using const_reference = const value_type&;
using size_type = *implementation-defined*; // see [container.requirements]
using difference_type = *implementation-defined*; // see [container.requirements]
using iterator = *implementation-defined*; // see [container.requirements]
using const_iterator = *implementation-defined*; // see [container.requirements]
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// [vector.cons], construct/copy/destroy
constexpr vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { }
constexpr explicit vector(const Allocator&) noexcept;
constexpr explicit vector(size_type n, const Allocator& = Allocator());
constexpr vector(size_type n, const T& value, const Allocator& = Allocator());
template<class InputIterator>
constexpr vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
constexpr vector(const vector& x);
constexpr vector(vector&&) noexcept;
constexpr vector(const vector&, const Allocator&);
constexpr vector(vector&&, const Allocator&);
constexpr vector(initializer_list<T>, const Allocator& = Allocator());
constexpr ~vector();
constexpr vector& operator=(const vector& x);
constexpr vector& operator=(vector&& x)
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
allocator_traits<Allocator>::is_always_equal::value);
constexpr vector& operator=(initializer_list<T>);
template<class InputIterator>
constexpr void assign(InputIterator first, InputIterator last);
constexpr void assign(size_type n, const T& u);
constexpr void assign(initializer_list<T>);
constexpr allocator_type get_allocator() const noexcept;
// iterators
constexpr iterator begin() noexcept;
constexpr const_iterator begin() const noexcept;
constexpr iterator end() noexcept;
constexpr const_iterator end() const noexcept;
constexpr reverse_iterator rbegin() noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr reverse_iterator rend() noexcept;
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// [vector.capacity], capacity
[[nodiscard]] constexpr bool empty() const noexcept;
constexpr size_type size() const noexcept;
constexpr size_type max_size() const noexcept;
constexpr size_type capacity() const noexcept;
constexpr void resize(size_type sz);
constexpr void resize(size_type sz, const T& c);
constexpr void reserve(size_type n);
constexpr void shrink_to_fit();
// element access
constexpr reference operator[](size_type n);
constexpr const_reference operator[](size_type n) const;
constexpr const_reference at(size_type n) const;
constexpr reference at(size_type n);
constexpr reference front();
constexpr const_reference front() const;
constexpr reference back();
constexpr const_reference back() const;
// [vector.data], data access
constexpr T* data() noexcept;
constexpr const T* data() const noexcept;
// [vector.modifiers], modifiers
template<class... Args> constexpr reference emplace_back(Args&&... args);
constexpr void push_back(const T& x);
constexpr void push_back(T&& x);
constexpr void pop_back();
template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
constexpr iterator insert(const_iterator position, const T& x);
constexpr iterator insert(const_iterator position, T&& x);
constexpr iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
constexpr iterator insert(const_iterator position,
InputIterator first, InputIterator last);
constexpr iterator insert(const_iterator position, initializer_list<T> il);
constexpr iterator erase(const_iterator position);
constexpr iterator erase(const_iterator first, const_iterator last);
constexpr void swap(vector&)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
constexpr void clear() noexcept;
};
template<class InputIterator, class Allocator = allocator<*iter-value-type*<InputIterator>>>
vector(InputIterator, InputIterator, Allocator = Allocator())
-> vector<*iter-value-type*<InputIterator>, Allocator>;
}

An incomplete type T may be used when instantiating vector
if the allocator meets the
allocator completeness requirements.

```
constexpr explicit vector(const Allocator&) noexcept;
```

```
constexpr explicit vector(size_type n, const Allocator& = Allocator());
```

```
constexpr vector(size_type n, const T& value,
const Allocator& = Allocator());
```

```
template<class InputIterator>
constexpr vector(InputIterator first, InputIterator last,
const Allocator& = Allocator());
```

It makes order
N
calls to the copy constructor of
T
and order
reallocations if they are just input iterators.

```
constexpr size_type capacity() const noexcept;
```

```
constexpr void reserve(size_type n);
```

After
reserve(),
capacity()
is greater or equal to the argument of
reserve
if reallocation happens; and equal to the previous value of
capacity()
otherwise.

Reallocation happens at this point if and only if the current capacity is less than the
argument of
reserve().

If an exception is thrown
other than by the move constructor of a non-*Cpp17CopyInsertable* type,
there are no effects.

No reallocation shall take place during insertions that happen
after a call to reserve()
until an insertion would make the size of the vector
greater than the value of capacity().

```
constexpr void shrink_to_fit();
```

If an exception is thrown other than by the move constructor
of a non-*Cpp17CopyInsertable* T there are no effects.

```
constexpr void swap(vector& x)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
```

```
constexpr void resize(size_type sz);
```

```
constexpr void resize(size_type sz, const T& c);
```

```
constexpr iterator insert(const_iterator position, const T& x);
constexpr iterator insert(const_iterator position, T&& x);
constexpr iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
constexpr iterator insert(const_iterator position, InputIterator first, InputIterator last);
constexpr iterator insert(const_iterator position, initializer_list<T>);
template<class... Args> constexpr reference emplace_back(Args&&... args);
template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
constexpr void push_back(const T& x);
constexpr void push_back(T&& x);
```

Reallocation invalidates all the references, pointers, and iterators
referring to the elements in the sequence, as well as the past-the-end iterator.

If no reallocation happens, then
references, pointers, and iterators
before the insertion point remain valid
but those at or after the insertion point,
including the past-the-end iterator,
are invalidated.

If an exception is thrown other than by
the copy constructor, move constructor,
assignment operator, or move assignment operator of
T or by any InputIterator operation
there are no effects.

If an exception is thrown while inserting a single element at the end and
T is *Cpp17CopyInsertable* or is_nothrow_move_co