| 1 | <HTML> | 
|---|
| 2 | <!-- | 
|---|
| 3 | -- Copyright (c) Jeremy Siek 2000 | 
|---|
| 4 | -- | 
|---|
| 5 | -- Permission to use, copy, modify, distribute and sell this software | 
|---|
| 6 | -- and its documentation for any purpose is hereby granted without fee, | 
|---|
| 7 | -- provided that the above copyright notice appears in all copies and | 
|---|
| 8 | -- that both that copyright notice and this permission notice appear | 
|---|
| 9 | -- in supporting documentation.  Silicon Graphics makes no | 
|---|
| 10 | -- representations about the suitability of this software for any | 
|---|
| 11 | -- purpose.  It is provided "as is" without express or implied warranty. | 
|---|
| 12 | --> | 
|---|
| 13 | <Head> | 
|---|
| 14 | <Title>MultiPassInputIterator</Title> | 
|---|
| 15 | <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" | 
|---|
| 16 | ALINK="#ff0000"> | 
|---|
| 17 | <IMG SRC="../../boost.png" | 
|---|
| 18 | ALT="C++ Boost" width="277" height="86"> | 
|---|
| 19 |  | 
|---|
| 20 | <BR Clear> | 
|---|
| 21 |  | 
|---|
| 22 | <H2> | 
|---|
| 23 | <A NAME="concept:MultiPassInputIterator"></A> | 
|---|
| 24 | Multi-Pass Input Iterator | 
|---|
| 25 | </H2> | 
|---|
| 26 |  | 
|---|
| 27 | This concept is a refinement of <a | 
|---|
| 28 | href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>, | 
|---|
| 29 | adding the requirements that the iterator can be used to make multiple | 
|---|
| 30 | passes through a range, and that if <TT>it1 == it2</TT> and | 
|---|
| 31 | <TT>it1</TT> is dereferenceable then <TT>++it1 == ++it2</TT>. The | 
|---|
| 32 | Multi-Pass Input Iterator is very similar to the <a | 
|---|
| 33 | href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>. The | 
|---|
| 34 | only difference is that a <a | 
|---|
| 35 | href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a> | 
|---|
| 36 | requires the <TT>reference</TT> type to be <TT>value_type&</TT>, whereas | 
|---|
| 37 | MultiPassInputIterator is like <a | 
|---|
| 38 | href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> | 
|---|
| 39 | in that the <TT>reference</TT> type merely has to be convertible to | 
|---|
| 40 | <TT>value_type</TT>. | 
|---|
| 41 |  | 
|---|
| 42 |  | 
|---|
| 43 | <h3>Design Notes</h3> | 
|---|
| 44 |  | 
|---|
| 45 | comments by Valentin Bonnard: | 
|---|
| 46 |  | 
|---|
| 47 | <p> I think that introducing Multi-Pass Input Iterator isn't the right | 
|---|
| 48 | solution. Do you also want to define Multi-Pass Bidirectionnal Iterator | 
|---|
| 49 | and Multi-Pass Random Access Iterator ? I don't, definitly. It only | 
|---|
| 50 | confuses the issue. The problem lies into the existing hierarchy of | 
|---|
| 51 | iterators, which mixes movabillity, modifiabillity and lvalue-ness, | 
|---|
| 52 | and these are clearly independant. | 
|---|
| 53 |  | 
|---|
| 54 | <p> The terms Forward, Bidirectionnal and Random Access are about | 
|---|
| 55 | movabillity and shouldn't be used to mean anything else.  In a | 
|---|
| 56 | completly orthogonal way, iterators can be immutable, mutable, or | 
|---|
| 57 | neither.  Lvalueness of iterators is also orthogonal with | 
|---|
| 58 | immutabillity.  With these clean concepts, your Multi-Pass Input Iterator | 
|---|
| 59 | is just called a Forward Iterator. | 
|---|
| 60 |  | 
|---|
| 61 | <p> | 
|---|
| 62 | Other translations are:<br> | 
|---|
| 63 | std::Forward Iterator -> ForwardIterator & Lvalue Iterator<br> | 
|---|
| 64 | std::Bidirectionnal Iterator -> Bidirectionnal Iterator & Lvalue Iterator<br> | 
|---|
| 65 | std::Random Access Iterator -> Random Access Iterator & Lvalue Iterator<br> | 
|---|
| 66 |  | 
|---|
| 67 | <p> | 
|---|
| 68 | Note that in practice the only operation not allowed on my | 
|---|
| 69 | Forward Iterator which is allowed on std::Forward Iterator is | 
|---|
| 70 | <tt>&*it</tt>. I think that <tt>&*</tt> is rarely needed in generic code. | 
|---|
| 71 |  | 
|---|
| 72 | <p> | 
|---|
| 73 | reply by Jeremy Siek: | 
|---|
| 74 |  | 
|---|
| 75 | <p> | 
|---|
| 76 | The above analysis by Valentin is right on. Of course, there is | 
|---|
| 77 | the problem with backward compatibility. The current STL implementations | 
|---|
| 78 | are based on the old definition of Forward Iterator. The right course | 
|---|
| 79 | of action is to get Forward Iterator, etc. changed in the C++ standard. | 
|---|
| 80 | Once that is done we can drop Multi-Pass Input Iterator. | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | <br> | 
|---|
| 84 | <HR> | 
|---|
| 85 | <TABLE> | 
|---|
| 86 | <TR valign=top> | 
|---|
| 87 | <TD nowrap>Copyright © 2000</TD><TD> | 
|---|
| 88 | <a HREF="../../people/jeremy_siek.htm">Jeremy Siek</a>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>) | 
|---|
| 89 | </TD></TR></TABLE> | 
|---|
| 90 |  | 
|---|
| 91 | </BODY> | 
|---|
| 92 | </HTML> | 
|---|