22 Containers library [containers]

22.2 Container requirements [container.requirements]

22.2.3 Sequence containers [sequence.reqmts]

Table 78: 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
Effects: Prepends an object of type T constructed with std​::​forward<​Args​>(​args)....

Preconditions: T is Cpp17EmplaceConstructible into X from args.

Returns: a.front().
deque, forward_­list, list
a.emplace_­back(args)
reference
Effects: Appends an object of type T constructed with std​::​forward<​Args​>(​args)....

Preconditions: T is Cpp17EmplaceConstructible into X from args.
For vector, T is also Cpp17MoveInsertable into X.
Returns: a.back().
deque, list, vector
a.push_­front(t)
void
Effects: Prepends a copy of t.

Preconditions: T is Cpp17CopyInsertable into X.
deque, forward_­list, list
a.push_­front(rv)
void
Effects: Prepends a copy of rv.

Preconditions: T is Cpp17MoveInsertable into X.
deque, forward_­list, list
a.push_­back(t)
void
Effects: Appends a copy of t.

Preconditions: T is Cpp17CopyInsertable into X.
basic_­string, deque, list, vector
a.push_­back(rv)
void
Effects: Appends a copy of rv.

Preconditions: T is Cpp17MoveInsertable into X.
basic_­string, deque, list, vector
a.pop_­front()
void
Effects: Destroys the first element.

Preconditions: a.empty() is false.
deque, forward_­list, list
a.pop_­back()
void
Effects: Destroys the last element.

Preconditions: a.empty() is false.
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