Skip to content

Fix transform_view::iterator::iterator_category when iter_reference_t is not an lvalue ref #637

@morinmorin

Description

@morinmorin

Since iter_reference_t<transform_view::iterator> can be a type that is not an lvalue-reference, the current wording on its iterator_category needs to be fixed.

Proposed Resolution

Change [range.transform.iterator] p2 as follows:

+ \tcode{iterator::iterator_category} is defined as follows:
  — Let `C` denote the type `iterator_traits<iterator_t<Base>>::iterator_category`.
+ — If `is_lvalue_reference_v<iter_reference_t<iterator_t<Base>>>` is `true`,
    — If `C` models `derived_from<contiguous_iterator_tag>`, 
      then `iterator_category` denotes `random_access_iterator_tag`. 
    — Otherwise, `iterator_category` denotes `C`.
+ — Otherwise, `iterator_category` denotes `input_iterator_tag`.

Making iterator_category unconditionally input_iterator_tag would be the safest fix, but I think the above fix works fine.

(I'm planning to submit this to LWG in a few days.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions