Difference between revisions of "cpp/named req/Container"
From cppreference.com
m (Text replace - "/sidebar" to "/navbar") |
|||
Line 55: | Line 55: | ||
|{{c|swap(a,b)}} || void || {{c|a.swap(b)}} || || Constant<ref name="array">Linear for {{c|std::array}}</ref> | |{{c|swap(a,b)}} || void || {{c|a.swap(b)}} || || Constant<ref name="array">Linear for {{c|std::array}}</ref> | ||
|- | |- | ||
− | |{{c|a.size()}} || size_type || {{c|distance(a.begin(),a.end())}} || ||Constant | + | |{{c|a.size()}} || size_type || {{c|distance(a.begin(),a.end())}} || || Constant<ref name="list">Linear for {{c|std::list}}</ref> |
|- | |- | ||
|{{c|a.max_size()}} || size_type || b.size() where b is the largest possible container || || Constant | |{{c|a.max_size()}} || size_type || b.size() where b is the largest possible container || || Constant |
Revision as of 12:23, 20 June 2012
Template:cpp/concept/title Template:cpp/concept/navbar
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.
Contents |
Requirements
-
C
Container type -
T
Element type -
a
,b
Objects of typeC
Types
name | type | notes |
---|---|---|
value_type |
T | Template:concept |
reference |
lvalue of T | |
const_reference |
const lvalue of T | |
iterator |
iterator pointing to T | Template:concept convertible to const_iterator
|
const_iterator |
const iterator pointing to T | Template:concept |
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
|
Methods and operators
expression | return type | semantics | conditions | complexity | |
---|---|---|---|---|---|
C(); | C | Creates an empty container | Post: u.empty() == true | Constant | |
C(a) | C | Create a copy of a |
Pre: T must be Template:concept Post: a == X(a) |
Linear | |
a = b | C& | All elements of a are destroyed or move assigned to elements of b |
Post: a == b | Linear | |
(&a)->~C() | void | Destroy all elements and free all memory | Linear | ||
a.begin() | (const_)iterator | Iterator to the first element | Constant | ||
a.end() | (const_)iterator | Iterator to one passed the last element | 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 | Makes C Template:concept | Pre: T must be Template:concept | Linear | |
a != b | convertible to bool | !(a==b) | Linear | ||
a.swap(b) | void | exchanges the values of a and b | Constant[1] | ||
swap(a,b) | void | a.swap(b) | Constant[1] | ||
a.size() | size_type | distance(a.begin(),a.end()) | Constant[2] | ||
a.max_size() | size_type | b.size() where b is the largest possible container | Constant | ||
a.empty() | convertible to bool | a.begin() == a.end() | Constant | ||
notes | |||||
|
Other concepts
- C
- T