Created on 2007-06-10.00:00:00 last changed 171 months ago
[ Pre Bellevue: This issue needs to wait until the auto -> return language feature goes in. ]
Proposed resolution:
Change the synopsis in [reverse.iterator]:
template <class Iterator1, class Iterator2>typename reverse_iterator<Iterator>::difference_typeauto operator-( const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y) -> decltype(y.current - x.current);
Change [reverse.iter.opdiff]:
template <class Iterator1, class Iterator2>typename reverse_iterator<Iterator>::difference_typeauto operator-( const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y) -> decltype(y.current - x.current);Returns: y.current - x.current.
Change the synopsis in [move.iterator]:
template <class Iterator1, class Iterator2>typename move_iterator<Iterator>::difference_typeauto operator-( const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
Change [move.iter.nonmember]:
template <class Iterator1, class Iterator2>typename move_iterator<Iterator>::difference_typeauto operator-( const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());Returns: x.base() - y.base().
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].
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg3437 |
2010-10-21 18:28:33 | admin | set | messages: + msg3436 |
2007-06-10 00:00:00 | admin | create |