Topic: forward_iterator_tag


Author: kuhlins@anne.UCAR.EDU (Stefan Kuhlins)
Date: 1997/11/26
Raw View
The struct forward_iterator_tag inherits only from
input_iterator_tag but not from output_iterator_tag.

What's the reason for this? Or is it a bug?

- Stefan (kuhlins@wifo.uni-mannheim.de)
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/11/27
Raw View
Stefan Kuhlins wrote:
>
> The struct forward_iterator_tag inherits only from
> input_iterator_tag but not from output_iterator_tag.
>
> What's the reason for this? Or is it a bug?

It's intentionnal. The rationnal is that it's for
algo specialisation:

ret some_algo (args, input_iterator_tag);
ret some_algo (args, forward_iterator_tag);

Example: with a forward_iterator_tag you can compute
a distance; with an input_iterator_tag, you can't.

But, while implementing some_algo, you read from
the args, you don't write (well, you could, but not
in the standard ones). In this case you can simply
add an explicit specialisation for output_iterator_tag,
just calling the forward_iterator_tag version.

So there was no compelling reason to derived
forward_iterator_tag from output_iterator_tag.
But IMO there aren't compeling reasons not to
do it, so it should have been done.

--

Valentin Bonnard                mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://www.pratique.fr/~bonnardv/
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]