function template
<iterator>
std::nexttemplate <class ForwardIterator> ForwardIterator next (ForwardIterator it, typename iterator_traits<ForwardIterator>::difference_type n = 1);
Get iterator to next element
Returns an iterator pointing to the element that it would be pointing to if advanced n positions.it is not modified.
If it is a random-access iterator, the function uses just once operator+
or operator-
. Otherwise, the function uses repeatedly the increase or decrease operator (operator++
or operator--
) on the copied iterator until n elements have been advanced.
1
by default).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// next example
#include <iostream> // std::cout
#include <iterator> // std::next
#include <list> // std::list
#include <algorithm> // std::for_each
int main () {
std::list<int> mylist;
for (int i=0; i<10; i++) mylist.push_back (i*10);
std::cout << "mylist:";
std::for_each (mylist.begin(),
std::next(mylist.begin(),5),
[](int x) {std::cout << ' ' << x;} );
std::cout << '\n';
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4