Created on 2002-10-23.00:00:00 last changed 171 months ago
[ Comments from Dave Abrahams: IMO we should resolve 386 by just saying that the return type of reverse_iterator's operator[] is unspecified, allowing the random access iterator requirements to impose an appropriate return type. If we accept 299's proposed resolution (and I think we should), the return type will be readable and writable, which is about as good as we can do. ]
Proposed resolution:
In [reverse.iter.requirements] change:
reference operator[](difference_type n) const;
to:
unspecified operator[](difference_type n) const; // see [random.access.iterators]
In [reverse.iter.op-=], reverse_iterator<>::operator[] is specified as having a return type of reverse_iterator::reference, which is the same as iterator_traits<Iterator>::reference. (Where Iterator is the underlying iterator type.)
The trouble is that Iterator's own operator[] doesn't necessarily have a return type of iterator_traits<Iterator>::reference. Its return type is merely required to be convertible to Iterator's value type. The return type specified for reverse_iterator's operator[] would thus appear to be impossible.
With the resolution of issue 299, the type of a[n] will continue to be required (for random access iterators) to be convertible to the value type, and also a[n] = t will be a valid expression. Implementations of reverse_iterator will likely need to return a proxy from operator[] to meet these requirements. As mentioned in the comment from Dave Abrahams, the simplest way to specify that reverse_iterator meet this requirement to just mandate it and leave the return type of operator[] unspecified.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg2436 |
2010-10-21 18:28:33 | admin | set | messages: + msg2435 |
2002-10-23 00:00:00 | admin | create |