Topic: Iterator IS-A Const Iterator but iterator IS-NOT-A const_iterator (Was: Defect Report: member == in container iterators considered harmful)
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/08/19 Raw View
Bill Wade wrote:
> Valentin Bonnard wrote in message <37BAC0EC.7C43@wanadoo.fr>...
> >
> >Bill Wade wrote:
> >
> >> 2) class iterator: public const_iterator { ... }; // inherit
> operator==()
> >
> >At any rate, no. An iterator IS-NOT-A const iterator.
>
> If it makes you feel better use
> class iterator: const_iterator { public: using const_iterator::operator==;
> ... };
>
> However I'd argue that iterator IS-very-close-to-being-A const_iterator.
It is as a concept, not as a class.
> Almost anything you can do with a const iterator you can also do with an
> iterator.
Anything, since there is a conversion <g>
Seriously, everything allowed with a Const Iterator is
also allowed with an Iterator.
I would say that at the _concept_ of Iterator IS-A Const
Iterator but that a particular iterator _instance_ cannot
be treated as a const_iterator _instance_.
--
Valentin Bonnard
[ 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 ]