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). 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. |
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 |