Expression | Return Type | Precondition |
---|---|---|
*r | reference | r is dereferenceable (see below) |
++r | It& | r is incrementable (see below) |
迭代器(Iterator)是用来遍历容器中的每一个元素。迭代器可以被认为一个抽象的指针。
Dereferenceable iterators 解引用迭代
Iterators for which the behavior of the expression *i is defined are called dereferenceable.
Iterators are not dereferenceable if:
1、they are past-the-end iterators or before-begin iterators.
2、they were invalidated by one of the iterator-invalidating operations on the sequence to which they refer.
iterators for which the behavior of the expression ++i is defined are called incrementable.
在迭代器中使用 ++i,返回新的迭代器。