Date
2007-06-10.00:00:00
Message id
3435

Content

In C++03 the difference between two reverse_iterators

ri1 - ri2

is possible to compute only if both iterators have the same base iterator. The result type is the difference_type of the base iterator.

In the current draft, the operator is defined as [reverse.iter.opdiff]

template<class Iterator1, class Iterator2>
typename reverse_iterator<Iterator>::difference_type
   operator-(const reverse_iterator<Iterator1>& x,
                    const reverse_iterator<Iterator2>& y);

The return type is the same as the C++03 one, based on the no longer present Iterator template parameter.

Besides being slightly invalid, should this operator work only when Iterator1 and Iterator2 has the same difference_type? Or should the implementation choose one of them? Which one?

The same problem now also appears in operator-() for move_iterator [move.iter.nonmember].