Expression | Return type | Assertion/note |
pre-/post-condition | ||
X(n, t) X u(n, t); | Postconditions: distance(begin(), end()) == n Effects: 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). | |
X(il) | Equivalent to X(il.begin(), il.end()) | |
a = il | X& | All existing
elements of a are either assigned to or destroyed. |
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]). |
a.insert(p, il) | iterator | a.insert(p, il.begin(), il.end()). |
a.erase(q) | iterator | |
a.erase(q1,q2) | iterator | |
a.clear() | void | Invalidates all references, pointers, and
iterators referring to the elements of a and may invalidate the past-the-end iterator. |
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. |
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. |
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.
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 replaceare called with a type InputIterator that does not qualify as an input iterator, then these functions shall not participate in overload resolution.
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 | Effects: Destroys the first element. | deque,
forward_list,
list |
a.pop_back() | void | Effects: Destroys the last element. | 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 |