Expression | Return type | Assertion/note |
pre-/post-condition | ||
X(n, t) X u(n, t); | Postconditions: distance(begin(), end()) == n 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 forward iterator requirements ([forward.iterators]), T
shall also be
MoveInsertable into X. Each iterator in the range [i, j) shall be dereferenced exactly once. Postconditions: distance(begin(), end()) == distance(i, j) 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 shall also be
MoveInsertable into X, MoveConstructible, MoveAssignable,
and swappable ([swappable.requirements]). Each iterator in the range [i, j) shall be dereferenced exactly once. Inserts copies of elements in [i, j) before p |
a.insert(p, il) | iterator | a.insert(p, il.begin(), il.end()). |
a.erase(q) | iterator | |
a.erase(q1,q2) | iterator | |
a.clear() | void | Destroys all elements in a. 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
shall also be
MoveInsertable into X. |
a.assign(il) | void | a.assign(il.begin(), il.end()). |
a.assign(n,t) | void |
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 | Prepends a copy of t. | deque,
forward_list,
list |
a.push_front(rv) | void | Prepends a copy of rv. | deque,
forward_list,
list |
a.push_back(t) | void | Appends a copy of t. | basic_string,
deque,
list,
vector |
a.push_back(rv) | void | Appends a copy of rv. | basic_string,
deque,
list,
vector |
a.pop_front() | void | Destroys the first element. | deque,
forward_list,
list |
a.pop_back() | void | 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 |