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

Created on 2019-09-13.00:00:00, last changed 2019-11-04.20:10:00.

Messages

Date: 2019-11-04.20:10:00

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: 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
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