A Container is an object used to store other objects and taking care of the management of the memory used by the objects it contains.
C
container type; T
element type; a
, b
objects of type C
. name | type | notes |
---|---|---|
value_type | T | Eraseable |
reference | T& | |
const_reference | const T& | |
iterator | iterator pointing to T |
LegacyForwardIterator convertible to const_iterator |
const_iterator | const iterator pointing to T | LegacyForwardIterator |
difference_type | signed integer | must be the same as iterator_traits::difference_type for iterator and const_iterator |
size_type | unsigned integer | large enough to represent all positive values of difference_type |
expression | return type | semantics | conditions | complexity | |
---|---|---|---|---|---|
C() | C | creates an empty container | Post: C().empty() == true | Constant | |
C(a) | C | creates a copy of a
| Pre: T must be CopyInsertable Post: a == C(a) | Linear | |
a = b | C& | destroys or move-assigns all elements of a from elements of b
| Post: a == b | Linear | |
a.~C() | void | destroys all elements of a and frees all memory | Linear | ||
a.begin() | (const_)iterator | Iterator to the first element of a
| Constant | ||
a.end() | (const_)iterator | Iterator to one past the last element of a
| Constant | ||
a.cbegin() (since C++11)
| const_iterator | const_cast<const C&>(a).begin() | Constant | ||
a.cend() (since C++11)
| const_iterator | const_cast<const C&>(a).end() | Constant | ||
a == b | convertible to bool | std::equal(a.begin(), a.end(), b.begin(), b.end()) (since C++14) | Pre: T must be EqualityComparable | Constant[1] if a.size() != b.size() , linear otherwise |
|
a != b | convertible to bool | !(a == b) | Linear | ||
a.swap(b) | void | exchanges the values of a and b | Constant[2][3] | ||
swap(a, b) | void | a.swap(b) | Constant[2] | ||
a.size() | size_type | distance(a.begin(), a.end()) | Constant[3] | ||
a.max_size() | size_type | b.size() where b is the largest possible container | Constant[3] | ||
a.empty() | convertible to bool | a.begin() == a.end() | Constant | ||
notes | |||||
|
Given.
in the expressions | (since C++14) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/named_req/Container