Title
transform_view::iterator has incorrect iterator_category
Status
c++20
Section
[range.transform.iterator]
Submitter
Michel Morin

Created on 2019-10-03.00:00:00 last changed 45 months ago

Messages

Date: 2020-02-10.19:48:51

Proposed resolution:

This wording is relative to N4830.

  1. Modify [range.transform.iterator] as indicated:

    -2- iterator::iterator_category is defined as follows: Let C denote the type iterator_traits<iterator_t<Base>>::iterator_category.

    1. (2.?) — If is_lvalue_reference_v<invoke_result_t<F&, range_reference_t<Base>>> is true,

      1. (2.?.?) — If C models derived_from<contiguous_iterator_tag>, then iterator_category denotes random_access_iterator_tag;

      2. (2.?.?) — Ootherwise, iterator_category denotes C.

    2. (2.?) — Otherwise, iterator_category denotes input_iterator_tag.

Date: 2020-02-10.00:00:00

[ 2020-02-10 Move to Immediate Monday afternoon in Prague ]

Date: 2019-11-15.00:00:00

[ 2019-11-06, Tim updates P/R based on Belfast LWG evening session discussion ]

The check in the original P/R is incorrect; we want to check the transformation's result, not the base iterator.

Date: 2019-10-31.00:00:00

[ 2019-10-31 Issue Prioritization ]

Priority to 1 after reflector discussion.

Previous resolution [SUPERSEDED]:

This wording is relative to N4830.

  1. Modify [range.transform.iterator] as indicated:

    -2- iterator::iterator_category is defined as follows: Let C denote the type iterator_traits<iterator_t<Base>>::iterator_category.

    1. (2.?) — If is_lvalue_reference_v<iter_reference_t<iterator_t<Base>>> is true,

      1. (2.?.?) — If C models derived_from<contiguous_iterator_tag>, then iterator_category denotes random_access_iterator_tag;

      2. (2.?.?) — Ootherwise, iterator_category denotes C.

    2. (2.?) — Otherwise, iterator_category denotes input_iterator_tag.

Date: 2019-10-03.00:00:00

When the transformation function returns an rvalue, transform_view::iterator cannot model cpp17-forward-iterator. However, similar to LWG 3291, the current wording on transform_view::iterator::iterator_category does not consider this.

As Casey Carter pointed out here, the proposed wording below does not consider input_iterator that is not cpp17-input-iterator (this problem is not specific to the PR; it's pervasive in adapted iterators) and concepts-based determination would be a better fix for issues around iterator_category. But anyway, I consider this PR as a minimal fix at the moment.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-10 19:48:51adminsetmessages: + msg11033
2020-02-10 19:48:51adminsetstatus: new -> immediate
2019-11-06 22:59:16adminsetmessages: + msg10770
2019-10-31 19:35:45adminsetmessages: + msg10720
2019-10-10 18:16:07adminsetmessages: + msg10692
2019-10-03 00:00:00admincreate