Topic: X::iterator()!=X::const_iterator()?
Author: David Vandevoorde <daveed@cup.hp.com>
Date: 1998/02/22 Raw View
Could someone confirm that the following comparison
between an iterator and const_iterator into the same
container is illegal?
#include <list>
int main() {
typedef std::list<int> L;
L l;
L::iterator it1 = l.begin();
L::const_iterator it2 = l.begin();
return it1!=it2;
}
I noticed that the WP says that L::iterator is ``convertible
to L::const_iterator'', but even if it means ``implicitly
convertible'' that may not be enough to ensure that above
works since user-defined conversions are not considered in
the template deduction process.
Is this intentional?
(I checked a few popular library implementations and
they indeed cause the above to be illegal.)
Daveed
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]