stand :: advance
The advance () function increments the position of the iterator passed as an argument. Thus, the function allows the iterator to move forward (or backward) by more than one element:
#include <iterator> void advance (InputIterator& pos, Dist n)
- Allows you to enter an input iterator step n elements forward ( or backward ).
- For bidirectional and random access iterators, n can be negative to go backward.
- Dist - type of template. Usually it should be an integral type, since operations such as <, ++, - and comparisons with 0 are called.
- Note that advance () does not check if it crosses the end () of the sequence (it cannot check, because iterators do not know at all the containers on which they work). Thus, a call to this function can lead to undefined behavior, because a call to the ++ operator to complete the sequence is undefined.
std :: next (and std::prev new in C ++ 11)
#include <iterator> ForwardIterator next (ForwardIterator pos) ForwardIterator next (ForwardIterator pos, Dist n)
- Sets the position that the front iterator pos should have if it moved forward 1 or n positions.
- For bidirectional and random access iterators, n can be negative to get previous ositions.
- Dist is the type std :: iterator_traits :: difference_type.
- A forward call (pos, n) for an internal temporary object.
- Note that next () does not check if it intersects the end () of the sequence. Thus, you must ensure that the result is valid before the caller.
specify The C++ Standard Library Second Edition
billz Feb 22 '13 at 5:03 2013-02-22 05:03
source share