Created on 2000-11-27.00:00:00 last changed 57 months ago
[ 2020-03-29; Jonathan Wakely comments ]
The issue title is misleading, it is not about comparing to const-qualified reverse_iterators, but comparing to reverse_iterator<const-iterator>.
[ Lillehammer: We now have implementation experience, and agree that this solution is safe and correct. ]
[ Copenhagen: The LWG is concerned that the proposed resolution introduces new overloads. Experience shows that introducing overloads is always risky, and that it would be inappropriate to make this change without implementation experience. It may be desirable to provide this feature in a different way. ]
Proposed resolution:
Section: [reverse.iterator] add/change the following declarations:
A) Add a templated assignment operator, after the same manner as the templated copy constructor, i.e.: template < class U > reverse_iterator < Iterator >& operator=(const reverse_iterator< U >& u); B) Make all global functions (except the operator+) have two template parameters instead of one, that is, for operator ==, !=, <, >, <=, >=, - replace: template < class Iterator > typename reverse_iterator< Iterator >::difference_type operator-( const reverse_iterator< Iterator >& x, const reverse_iterator< Iterator >& y); with: template < class Iterator1, class Iterator2 > typename reverse_iterator < Iterator1 >::difference_type operator-( const reverse_iterator < Iterator1 > & x, const reverse_iterator < Iterator2 > & y);
Also make the addition/changes for these signatures in [reverse.iter.ops].
This came from an email from Steve Cleary to Fergus in reference to issue 179. The library working group briefly discussed this in Toronto and believed it should be a separate issue. There was also some reservations about whether this was a worthwhile problem to fix.
Steve said: "Fixing reverse_iterator. std::reverse_iterator can (and should) be changed to preserve these additional requirements." He also said in email that it can be done without breaking user's code: "If you take a look at my suggested solution, reverse_iterator doesn't have to take two parameters; there is no danger of breaking existing code, except someone taking the address of one of the reverse_iterator global operator functions, and I have to doubt if anyone has ever done that. . . But, just in case they have, you can leave the old global functions in as well -- they won't interfere with the two-template-argument functions. With that, I don't see how any user code could break."
History | |||
---|---|---|---|
Date | User | Action | Args |
2020-03-29 10:04:00 | admin | set | messages: + msg11170 |
2010-10-21 18:28:33 | admin | set | messages: + msg2098 |
2010-10-21 18:28:33 | admin | set | messages: + msg2097 |
2010-10-21 18:28:33 | admin | set | messages: + msg2096 |
2000-11-27 00:00:00 | admin | create |