Title
move_iterator operator+() has incorrect constraints
Status
c++23
Section
[move.iter.nonmember]
Submitter
Bo Persson

Created on 2019-09-13.00:00:00 last changed 13 months ago

Messages

Date: 2021-10-14.09:56:08

Proposed resolution:

This wording is relative to N4835.

  1. Modify [move.iter.nonmember] as indicated:

    template<class Iterator>
      constexpr move_iterator<Iterator>
        operator+(iter_difference_t<Iterator> n, const move_iterator<Iterator>& x);
    

    -2- Constraints: x.base() + n is well-formed and has type Iterator.

    -3- Returns: x + n.

Date: 2021-10-14.00:00:00

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

Date: 2021-06-15.00:00:00

[ 2021-06-23; Reflector poll ]

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

Date: 2019-11-15.00:00:00

[ 2019-11-04; Casey comments and provides revised wording ]

After applying the P/R the Constraint element requires x + n to be well-formed (it always is, since that operation is unconstrained) and requires x + n to have type move_iterator<Iterator> (which it always does). Consequently, this Constraint is always satisfied and it has no normative effect. The intent of the change in P0896R4 was that this operator be constrained to require addition on the base iterator to be well-formed and have type Iterator, which ensures that the other semantics of this operation are implementable.

Date: 2019-10-31.00:00:00

[ 2019-10-31 Issue Prioritization ]

Priority to 3 after reflector discussion.

Previous resolution [SUPERSEDED]:

This wording is relative to N4830.

  1. Modify [move.iter.nonmember] as indicated:

    template<class Iterator>
      constexpr move_iterator<Iterator>
        operator+(iter_difference_t<Iterator> n, const move_iterator<Iterator>& x);
    

    -2- Constraints: x + n is well-formed and has type move_iterator<Iterator>.

    -3- Returns: x + n.

Date: 2019-09-13.00:00:00

Section [move.iter.nonmember]/2-3 says:

template<class Iterator>
  constexpr move_iterator<Iterator>
    operator+(iter_difference_t<Iterator> n, const move_iterator<Iterator>& x);

Constraints: x + n is well-formed and has type Iterator.

Returns: x + n.

However, the return type of this operator is move_iterator<Iterator>, so the expression x + n ought to have that type. Also, there is no operator+ that matches the constraints, so it effectively disables the addition.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2021-10-14 09:56:08adminsetmessages: + msg12114
2021-10-14 09:56:08adminsetstatus: voting -> wp
2021-09-29 12:57:28adminsetstatus: ready -> voting
2021-06-23 14:16:45adminsetmessages: + msg11953
2021-06-23 14:16:45adminsetstatus: new -> ready
2019-11-04 20:10:00adminsetmessages: + msg10742
2019-10-31 18:46:30adminsetmessages: + msg10711
2019-09-18 18:35:39adminsetmessages: + msg10657
2019-09-13 00:00:00admincreate