Title
iota_view's iterator's binary operator+ should be improved
Status
c++23
Section
[range.iota.iterator]
Submitter
Zoe Carver

Created on 2021-08-14.00:00:00 last changed 12 months ago

Messages

Date: 2021-10-14.09:56:08

Proposed resolution:

This wording is relative to N4892.

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

    friend constexpr iterator operator+(iterator i, difference_type n)
      requires advanceable<W>;
    

    -20- Effects: Equivalent to:

    return i += n; 
    return i;
    
    friend constexpr iterator operator+(difference_type n, iterator i)
      requires advanceable<W>;
    

    -21- Effects: Equivalent to: return i + n;

    friend constexpr iterator operator-(iterator i, difference_type n)
      requires advanceable<W>;
    

    -22- Effects: Equivalent to:

    return i -= n;
    return i;
    
Date: 2021-10-14.00:00:00

[ 2021-10-14 Approved at October 2021 virtual plenary. Status changed: Voting → WP. ]

Date: 2021-08-15.00:00:00

[ 2021-08-20; Reflector poll ]

Set status to Tentatively Ready after six votes in favour during reflector poll.

Date: 2021-08-14.00:00:00

iota_view's iterator's operator+ could avoid a copy construct by doing "i += n; return i" rather than "return i += n;" as seen in [range.iota.iterator].

This is what libc++ has implemented and shipped, even though it may not technically be conforming (if a program asserted the number of copies, for example).

It might be good to update this operator and the minus operator accordingly.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-10-14 09:56:08adminsetmessages: + msg12137
2021-10-14 09:56:08adminsetstatus: voting -> wp
2021-09-29 12:57:28adminsetstatus: ready -> voting
2021-08-20 17:16:53adminsetmessages: + msg12004
2021-08-20 17:16:53adminsetstatus: new -> ready
2021-08-14 20:06:41adminsetmessages: + msg11987
2021-08-14 00:00:00admincreate