Created on 2013-12-24.00:00:00 last changed 90 months ago
Proposed resolution:
This wording is relative to N3797.
Change [iterator.synopsis], header <iterator> synopsis, and [iterator.operations] before p.6 as indicated:
template <classForwardInputIterator>ForwardInputIterator next(ForwardInputIterator x, typename std::iterator_traits<ForwardInputIterator>::difference_type n = 1);
[ Lenexa 2015-05-07: Move to Ready ]
In LWG 1011, std::next and std::prev were changed from accepting InputIterator to accepting ForwardIterator. This needlessly excludes perfectly legitimate use cases. Consider the following hypothetical range-based implementation of drop, which creates a view of a range without the first n elements:
template<typename Distance, typename InputRange> iterator_range<range_iterator_t<InputRange>> drop(Distance n, InputRange& rng) { return make_iterator_range( std::next(std::begin(rng), n), std::end(rng) ); }
I believe this to be a legitimate use case that is currently outlawed by the standard without cause. See the discussion beginning at c++std-lib-35313 for an in-depth discussion of the issue, in which Howard Hinnant agreed that it was a defect.
(Some discussion then ensued about whether an overload should be added that only accepts rvalue InputIterators to avoid the surprise that issue 1011 sought to address. I make no such attempt, nor do I believe it to be necessary.) Suggested resolution: Back out the resolution of 1011.History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2015-10-27 16:52:45 | admin | set | status: ready -> wp |
2015-05-22 19:14:31 | admin | set | messages: + msg7436 |
2015-05-22 19:14:31 | admin | set | status: new -> ready |
2014-01-12 22:13:32 | admin | set | messages: + msg6791 |
2013-12-24 00:00:00 | admin | create |