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(); }
12345678910111213141516
// 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; }
foo has 3 elements