Talk:cpp/iterator/distance

In C++11, what does it mean for a RandomAccessIterator to be reachable from another one?

If InputIt is not RandomAccessIterator, the behavior is undefined if last is not reachable from first by (possibly repeatedly) incrementing first. If InputIt is RandomAccessIterator, the behavior is undefined if last is not reachable from first and first is not reachable from last.

I see that the sentence above does not mention incrementing for RandomAccessIterators. Does that mean that other means of checking reachability exist? 85.18.102.222 05:44, 13 June 2017 (PDT)


 * well, you could say a RA Iterator j is reachable from RA Iterator i if there exists an integer n such that i+n == j. The standard definition of iterator reachability is indeed in terms of a finite sequence of preincrements iterator.requirements.general/8, since i+n is defined in terms of a sequence of n preincrements random.access.iterators. --Cubbi (talk) 06:09, 13 June 2017 (PDT)