Title
Minimal improvements to elements_view::iterator
Status
c++23
Section
[range.elements.iterator]
Submitter
Michael Schellenberger Costa

Created on 2020-10-28.00:00:00 last changed 5 months ago

Messages

Date: 2021-02-26.17:31:29

Proposed resolution:

This wording is relative to N4868.

This wording intentionally only touches operator++(int) and not operator-, see the 2020-11-01 comment for the reason why.

  1. Modify [range.elements.iterator], class template elements_view::iterator synopsis, as indicated:

    […]
    constexpr iterator& operator++();
    constexpr void operator++(int) requires (!forward_range<Base>);
    constexpr iterator operator++(int) requires forward_range<Base>;
    […]
    
    […]
    constexpr void operator++(int) requires (!forward_range<Base>);
    

    -6- Effects: Equivalent to: ++current_.

    constexpr iterator operator++(int) requires forward_range<Base>;
    
    […]
Date: 2021-02-26.00:00:00

[ 2021-02-26 Approved at February 2021 virtual plenary. Status changed: Tentatively Ready → WP. ]

Date: 2020-11-15.00:00:00

[ 2020-11-15; Reflector prioritization ]

Set priority to 0 and status to Tentatively Ready after five votes in favour during reflector discussions.

Date: 2020-11-15.00:00:00

[ 2020-11-01; Daniel comments ]

Bullet (2) of the discussion has already been resolved by LWG 3483, it has therefore been omitted from the proposed wording below.

Date: 2020-10-28.00:00:00

During code review of elements_view for MSVC-STL we found two issues that should be easily addressed:

  1. elements_view::iterator constraints both operator++(int) member functions

    constexpr void operator++(int) requires (!forward_range<Base>);
    constexpr iterator operator++(int) requires forward_range<Base>;  
    

    However, given that a constrained method would be preferred we only need to constrain one of those. The proposal would be to remove the constraint from the void returning overload and change the declaration to

    constexpr void operator++(int);
    constexpr iterator operator++(int) requires forward_range<Base>;  
    
  2. elements_view::iterator operator- is constrained as follows:

    friend constexpr difference_type operator-(const iterator& x, const iterator& y)
      requires random_access_range<Base>; 
    

    However, that requires its base to have operator- defined. We should change the constraint to sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>:

    friend constexpr difference_type operator-(const iterator& x, const iterator& y)
      requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
    
History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-02-26 17:31:29adminsetmessages: + msg11702
2021-02-26 17:31:29adminsetstatus: ready -> wp
2020-11-15 13:41:13adminsetmessages: + msg11605
2020-11-15 13:41:13adminsetstatus: new -> ready
2020-11-01 16:20:16adminsetmessages: + msg11522
2020-11-01 16:20:16adminsetmessages: + msg11521
2020-10-28 00:00:00admincreate