| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
operator+ | ||||
(C++20) | ||||
(C++20) | ||||
(C++14) |
Defined in header <iterator> | ||
template<class Iter> reverse_iterator<Iter> operator+ | (constexpr since C++17) (until C++23) | |
template<class Iter> constexpr reverse_iterator<Iter> operator+ | (since C++23) | |
Returns the iteratorit incremented byn. In fact, the underlying iterator is decremented byn.
Contents |
| n | - | the number of positions to increment the iterator |
| it | - | the iterator adaptor to increment |
reverse_iterator<Iter>(it.base()- n)
#include <iostream>#include <iterator>#include <list>#include <vector> int main(){{std::vector v{0,1,2,3};std::reverse_iterator<std::vector<int>::iterator> ri1{std::reverse_iterator{v.rbegin()}};std::cout<<*ri1<<' ';// 3std::reverse_iterator<std::vector<int>::iterator> ri2{2+ ri1};std::cout<<*ri2<<' ';// 1} {std::list l{5,6,7,8};std::reverse_iterator<std::list<int>::iterator> ri1{std::reverse_iterator{l.rbegin()}};std::cout<<*ri1<<'\n';// 8// auto ri2{2 + ri1}; // Error: the underlying iterator does not// model random access iterator}}
Output:
3 1 8
advances or decrements thereverse_iterator(public member function)[edit] | |
| computes the distance between two iterator adaptors (function template)[edit] |