Created on 2020-06-06.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4861.
Modify [range.take.while.view], class template take_while_view synopsis, as indicated:
namespace std::ranges { template<view V, class Pred> requires input_range<V> && is_object_v<Pred> && indirect_unary_predicate<const Pred, iterator_t<V>> class take_while_view : public view_interface<take_while_view<V, Pred>> { […] constexpr auto begin() requires (!simple-view<V>) { return ranges::begin(base_); } constexpr auto begin() const requires range<const V> && indirect_unary_predicate<const Pred, iterator_t<const V>> { return ranges::begin(base_); } constexpr auto end() requires (!simple-view<V>) { return sentinel<false>(ranges::end(base_), addressof(*pred_)); } constexpr auto end() const requires range<const V> && indirect_unary_predicate<const Pred, iterator_t<const V>> { return sentinel<true>(ranges::end(base_), addressof(*pred_)); } }; }
[ 2020-11-09 Approved In November virtual meeting. Status changed: Ready → WP. ]
[ 2020-07-17; Moved to Ready in telecon ]
The const overloads of take_while_view::begin and take_while_view::end are underconstrained: they should require the predicate to model indirect_unary_predicate<iterator_t<const V>>. A simple example is
#include <ranges> auto v = std::views::single(1) | std::views::take_while([](int& x) { return true;}); static_assert(std::ranges::range<decltype(v)>); static_assert(std::ranges::range<decltype(v) const>); bool b = std::ranges::cbegin(v) == std::ranges::cend(v);
Here, the static_asserts pass but the comparison fails to compile. The other views using indirect_unary_predicate (filter_view and drop_while_view) do not have this problem because they do not support const-iteration.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2020-11-09 20:31:48 | admin | set | messages: + msg11549 |
2020-11-09 20:31:48 | admin | set | status: ready -> wp |
2020-07-17 22:37:26 | admin | set | messages: + msg11395 |
2020-07-17 22:37:26 | admin | set | status: new -> ready |
2020-06-06 13:46:40 | admin | set | messages: + msg11325 |
2020-06-06 00:00:00 | admin | create |