Created on 2019-09-10.00:00:00 last changed 45 months ago
Proposed resolution:
This wording is relative to N4830.
Modify [range.subrange] as indicated:
namespace std::ranges { […]template<class T, class U, class V> concept pair-like-convertible-to = // exposition only !range<T> && pair-like<remove_reference_t<T>> && requires(T&& t) { { get<0>(std::forward<T>(t)) } -> convertible_to<U>; { get<1>(std::forward<T>(t)) } -> convertible_to<V>; };[…] template<input_or_output_iterator I, sentinel_for<I> S = I, subrange_kind K = sized_sentinel_for<S, I> ? subrange_kind::sized : subrange_kind::unsized> requires (K == subrange_kind::sized || !sized_sentinel_for<S, I>) class subrange : public view_interface<subrange<I, S, K>> { private: […] public: […]template<not-same-as<subrange> PairLike> requires pair-like-convertible-to<PairLike, I, S> constexpr subrange(PairLike&& r) requires (!StoreSize) : subrange{std::get<0>(std::forward<PairLike>(r)), std::get<1>(std::forward<PairLike>(r))} {} template<pair-like-convertible-to<I, S> PairLike> constexpr subrange(PairLike&& r, make-unsigned-like-t(iter_difference_t<I>) n) requires (K == subrange_kind::sized) : subrange{std::get<0>(std::forward<PairLike>(r)), std::get<1>(std::forward<PairLike>(r)), n} {}[…] }; […] }
[ 2019-11 Status to Ready after LWG discussion Friday in Belfast. ]
[ 2019-10 Priority set to 1 and status to LEWG after reflector discussion ]
Just because a pair is holding two iterators, it doesn't mean those two iterators denote a valid range. Implicitly converting such pair-like types to a subrange is dangerous and should be disallowed.
Suggested priority P1. Implementation experience: range-v3's subrange lacks these constructors.History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-25 10:48:01 | admin | set | status: wp -> c++20 |
2020-02-24 16:02:59 | admin | set | status: voting -> wp |
2020-01-17 04:54:50 | admin | set | status: ready -> voting |
2019-11-08 15:56:47 | admin | set | messages: + msg10807 |
2019-11-08 15:56:47 | admin | set | status: lewg -> ready |
2019-10-07 02:21:30 | admin | set | messages: + msg10684 |
2019-10-07 02:21:30 | admin | set | status: new -> lewg |
2019-09-15 14:48:22 | admin | set | messages: + msg10633 |
2019-09-10 00:00:00 | admin | create |