function template
<iterator>
std::operator- (move_iterator)template <class Iterator1, class Iterator2> auto operator- (const move_iterator<Iterator>& lhs, const move_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 the base iterators of lhs and rhs.
This operator is also overloaded as a member function to return a move iterator offset by -n
element positions (see move_iterator::operator-).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// subtracting move_iterators
#include <iostream> // std::cout
#include <iterator> // std::move_iterator
#include <string> // std::string
int main () {
std::string foo[] = {"one","two","three"};
std::move_iterator<std::string*> from (foo);
std::move_iterator<std::string*> until (foo);
until += sizeof(foo)/sizeof(std::string);
std::cout << "foo has " << (until-from) << " elements.\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