Topic: Why doesn't forward derive from output?


Author: kprateek88@yahoo.com (Prateek R Karandikar)
Date: Fri, 21 May 2004 21:32:04 +0000 (UTC)
Raw View
TC++PL (18.2):
"A random-access iterator can be used as a bidirectional iterator, a
bidirectional iterator as a forward iterator, and FORWARD iterator as
an input or OUTPUT iterator."

[Capitaliztion is mine]

A forward iterator can be used an an output iterator. Doesn't this
imply that std::forward_iterator_tag sould derive from
std::output_iterator_tag?

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To iterate is human, to recurse divine.
-L.Peter Deutsch
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: pjp@dinkumware.com ("P.J. Plauger")
Date: Sun, 23 May 2004 00:15:10 +0000 (UTC)
Raw View
"Prateek R Karandikar" <kprateek88@yahoo.com> wrote in message
news:607f883e.0405211301.3681b9b4@posting.google.com...

> TC++PL (18.2):
> "A random-access iterator can be used as a bidirectional iterator, a
> bidirectional iterator as a forward iterator, and FORWARD iterator as
> an input or OUTPUT iterator."
>
> [Capitaliztion is mine]
>
> A forward iterator can be used an an output iterator. Doesn't this
> imply that std::forward_iterator_tag sould derive from
> std::output_iterator_tag?

You'd think that, but actually the hierarchy is used for
dispatching among different algorithms depending on the
"strength" of the required iterator. The most general
algorithm handles the weakest case, and more specialized
versions take advantage of stronger iterators. Since output
iterator is the weakest case, and one that doesn't profit
from optizimation, you never have occasion to dispatch on
an iterator that might be an output iterator. So it need
not appear in the tag hierarchy.

HTH,

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]