function template
<iterator>
std::operator- (reverse_iterator)template <class Iterator> typename reverse_iterator<Iterator>::difference_type operator- ( const reverse_iterator<Iterator>& lhs, const reverse_iterator<Iterator>& rhs);
template <class Iterator1, class Iterator2> auto operator- (const reverse_iterator<Iterator>& lhs, const reverse_iterator<Iterator>& rhs) -> decltype (rhs.base()-lhs.base()) { return rhs.base()-lhs.base(); }
Subtraction operator
Returns the distance between lhs and rhs.The function returns the same as subtracting lhs's base iterator from rhs's base iterator.
objects (to the left- and right-hand side of the operator, respectively), having both the same template parameter (
Iterator).
objectss (to the left- and right-hand side of the operator, respectively) for whose
base iteratorsthe subtraction operation is defined.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// operator- on reverse_iterator
#include <iostream> // std::cout
#include <iterator> // std::reverse_iterator
#include <vector> // std::vector
int main () {
std::vector<int> myvector;
for (int i=0; i<10; i++) myvector.push_back(i);
std::reverse_iterator<std::vector<int>::iterator> from,until;
from = myvector.rbegin();
until = myvector.rend();
std::cout << "myvector has " << (until-from) << " elements.\n";
return 0;
}
myvector has 10 elements.
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