
on Fri Nov 09 2007, "JOAQUIN LOPEZ MU?Z" <joaquin-AT-tid.es> wrote:
De: David Abrahams <dave@boost-consulting.com>
on Fri Nov 09 2007, Thorsten Ottosen <nesotto-AT-cs.aau.dk> wrote: [...]
"template<class InputIterator> typename iterator_traits<InputIterator>::difference_type distance(InputIterator first, InputIterator last); 4 Effects: Returns the number of increments or decrements needed to get from first to last. 5 Requires: last shall be reachable from first."
How can one ever use decrements to get from first to last?
When InputIterator is a random access iterator, last < first does not violate the precondition.
I'm afraid (last<first) violates the precondition even with random access iterators, according to 24.1.6 and as explicitly acknowledged at http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#204 .
I don't see how to read the issue resolution so it says that.
This is IMHO an unfortunate decision by the committee and renders the "or decrements" bit in the effects clause of std::distance void and misleading.
I do agree that the decision is unfortunate. The wording is clearly misleading. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com