Reputation: 9097
Cannot manage to find it, hope somebody can help. There is a function in the std library which gets called upon an iterator and an unsigned number, which returns the iterator pointing to the object to which the input iterator would have pointed if advance would have been called onto it. Which function am I referring to? I'm sure it exists!
Upvotes: 1
Views: 398
Reputation: 873
Take a look at std::next function
http://en.cppreference.com/w/cpp/iterator/next
Upvotes: 1
Reputation: 171127
In C++11, there's std::next
(defined in <iterator>
). Before that, there was the same in boost, or you can write it yourself.
Upvotes: 2
Reputation: 2767
I'm sure there is no such function for input iterators. If you modify (increment) input iterators you invalidate other copies of it. So this function could only be implemented for forward iterators.
Upvotes: 2