| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
constexpr subrange next(std::iter_difference_t<I> n=1)const& requiresstd::forward_iterator<I>; | (1) | (since C++20) |
constexpr subrange next(std::iter_difference_t<I> n=1)&&; | (2) | (since C++20) |
Returns asubrange whosebegin_ is incremented (or decremented ifn is negative). The actual increment (or decrement) operation is performed byadvance().
subrange moved from*this.Contents |
| n | - | number of maximal increments of the iterator |
As described above.
The difference between this function andadvance() is that the latter performs the increment (or decrement) in place.
#include <array>#include <iterator>#include <print>#include <ranges> int main(){std::array arr{1,2,3,4,5,6,7}; std::ranges::subrange sub{std::next(arr.begin(),2),std::prev(arr.end(),2)};std::println("1) sub: {}", sub);std::println("2) sub: {}", sub.next());std::println("3) sub: {}", sub.next(2));}
Output:
1) sub: [3, 4, 5]2) sub: [4, 5]3) sub: [5]
obtains a copy of thesubrange with its iterator decremented by a given distance(public member function)[edit] | |
| advances the iterator by given distance (public member function)[edit] | |
(C++11) | increment an iterator (function template)[edit] |
(C++20) | increment an iterator by a given distance or to a bound (algorithm function object)[edit] |