This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
transform_view::iterator::value_type and iterator_category should
use const F&Section: 25.7.9.3 [range.transform.iterator] Status: C++23 Submitter: Tim Song Opened: 2021-06-06 Last modified: 2023-11-22
Priority: 2
View all other issues in [range.transform.iterator].
View all issues with C++23 status.
Discussion:
Iterators obtained from a const transform_view invoke the
transformation function as const, but the value_type and
iterator_category determination uses plain F&, i.e., non-const.
[2021-06-14; Reflector poll]
Set priority to 2 after reflector poll, send to SG9 for design clarification.
Should r and as_const(r) guarantee same elements?
[2022-07-08; Reflector poll]
SG9 has decided to proceed with this PR in its 2021-09-13 telecon and not block the issue for a paper on the more general const/non-const problem.
Set status to Tentatively Ready after five votes in favour during reflector poll.
[2022-07-15; LWG telecon: move to Ready]
[2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready → WP.]
Proposed resolution:
This wording is relative to N4885.
Modify 25.7.9.3 [range.transform.iterator] as indicated:
namespace std::ranges { templaterequires view && is_object_v && regular_invocable > && can-reference >> template class transform_view ::iterator { private: […] public: using iterator_concept = see below; using iterator_category = see below; // not always present using value_type = remove_cvref_t maybe-const F>&, range_reference_t<Base>>>; using difference_type = range_difference_t<Base>; […] }; } -1- […]
-2- The member typedef-nameiterator_categoryis defined if and only ifBasemodelsforward_range. In that case,iterator::iterator_categoryis defined as follows: LetCdenote the typeiterator_traits.Base>>::iterator_category
(2.1) — If
is_lvalue_reference_vismaybe-const F>&, range_reference_t<Base>>> true, then
(2.1.1) — […]
(2.1.2) — […]
(2.2) — Otherwise,
iterator_categorydenotesinput_iterator_tag.