Created on 2022-09-04.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to n4917.
Modify [view.interface.general] as indicated:
namespace std::ranges { template<class D> requires is_class_v<D> && same_as<D, remove_cv_t<D>> class view_interface { […] public: […] constexpr auto cbegin() requires input_range<D> { return ranges::cbegin(derived()); } constexpr auto cbegin() const requires input_range<const D> { return ranges::cbegin(derived()); } constexpr auto cend() requires input_range<D> { return ranges::cend(derived()); } constexpr auto cend() const requires input_range<const D> { return ranges::cend(derived()); } […] }; }
[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Immediate → WP. ]
[ Kona 2022-11-08; Accepted at joint LWG/SG9 session. Move to Immediate ]
[ 2022-09-25; Hewill provides improved wording ]
[ 2022-09-23; Reflector poll ]
Set priority to 2 after reflector poll.
This should be done for cend too.
Previous resolution [SUPERSEDED]:
This wording is relative to n4917.
Modify [view.interface.general] as indicated:
namespace std::ranges { template<class D> requires is_class_v<D> && same_as<D, remove_cv_t<D>> class view_interface { […] public: […] constexpr auto cbegin() requires input_range<D> { return ranges::cbegin(derived()); } constexpr auto cbegin() const requires input_range<const D> { return ranges::cbegin(derived()); } […] }; }
Currently, view_interface::cbegin simply returns ranges::cbegin(derived()), which returns the type alias const_iterator for its iterator, which requires that the template parameter I must model the input_iterator.
Given that view_interface::cbegin does not have any constraints, when D models only output_range, calling its cbegin() will result in a hard error inside the function body:
#include <ranges>
#include <vector>
int main() {
std::vector<int> v;
auto r = std::views::counted(std::back_inserter(v), 3);
auto b = r.cbegin(); // hard error
}
We should add a constraint for view_interface::cbegin that D must model input_range.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2022-11-17 00:42:33 | admin | set | messages: + msg13092 |
2022-11-17 00:42:33 | admin | set | status: immediate -> wp |
2022-11-11 02:39:56 | admin | set | status: ready -> immediate |
2022-11-10 23:33:20 | admin | set | messages: + msg13004 |
2022-11-10 23:33:20 | admin | set | status: new -> ready |
2022-09-25 06:36:20 | admin | set | messages: + msg12808 |
2022-09-23 15:44:07 | admin | set | messages: + msg12800 |
2022-09-06 15:53:57 | admin | set | messages: + msg12742 |
2022-09-04 00:00:00 | admin | create |