MultiPassInputIterator.html 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
  6. <title>MultiPassInputIterator</title>
  7. </head>
  8. <body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
  9. "#FF0000">
  10. <img src="../../boost.png" alt="C++ Boost" width="277" height=
  11. "86"><br clear="none">
  12. <h2><a name="concept:MultiPassInputIterator" id=
  13. "concept:MultiPassInputIterator"></a> Multi-Pass Input Iterator</h2>
  14. <p>This concept is a refinement of <a href=
  15. "http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>, adding
  16. the requirements that the iterator can be used to make multiple passes
  17. through a range, and that if <tt>it1 == it2</tt> and <tt>it1</tt> is
  18. dereferenceable then <tt>++it1 == ++it2</tt>. The Multi-Pass Input Iterator
  19. is very similar to the <a href=
  20. "http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>.
  21. The only difference is that a <a href=
  22. "http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>
  23. requires the <tt>reference</tt> type to be <tt>value_type&amp;</tt>,
  24. whereas MultiPassInputIterator is like <a href=
  25. "http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> in that
  26. the <tt>reference</tt> type merely has to be convertible to
  27. <tt>value_type</tt>.</p>
  28. <h3>Design Notes</h3>
  29. <p>comments by Valentin Bonnard:</p>
  30. <p>I think that introducing Multi-Pass Input Iterator isn't the right
  31. solution. Do you also want to define Multi-Pass Bidirectionnal Iterator and
  32. Multi-Pass Random Access Iterator ? I don't, definitly. It only confuses
  33. the issue. The problem lies into the existing hierarchy of iterators, which
  34. mixes movabillity, modifiabillity and lvalue-ness, and these are clearly
  35. independant.</p>
  36. <p>The terms Forward, Bidirectionnal and Random Access are about
  37. movabillity and shouldn't be used to mean anything else. In a completly
  38. orthogonal way, iterators can be immutable, mutable, or neither. Lvalueness
  39. of iterators is also orthogonal with immutabillity. With these clean
  40. concepts, your Multi-Pass Input Iterator is just called a Forward
  41. Iterator.</p>
  42. <p>Other translations are:<br>
  43. std::Forward Iterator -&gt; ForwardIterator &amp; Lvalue Iterator<br>
  44. std::Bidirectionnal Iterator -&gt; Bidirectionnal Iterator &amp; Lvalue
  45. Iterator<br>
  46. std::Random Access Iterator -&gt; Random Access Iterator &amp; Lvalue
  47. Iterator<br></p>
  48. <p>Note that in practice the only operation not allowed on my Forward
  49. Iterator which is allowed on std::Forward Iterator is <tt>&amp;*it</tt>. I
  50. think that <tt>&amp;*</tt> is rarely needed in generic code.</p>
  51. <p>reply by Jeremy Siek:</p>
  52. <p>The above analysis by Valentin is right on. Of course, there is the
  53. problem with backward compatibility. The current STL implementations are
  54. based on the old definition of Forward Iterator. The right course of action
  55. is to get Forward Iterator, etc. changed in the C++ standard. Once that is
  56. done we can drop Multi-Pass Input Iterator.<br></p>
  57. <hr>
  58. <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
  59. "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
  60. height="31" width="88"></a></p>
  61. <p>Revised
  62. <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
  63. December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
  64. <table summary="">
  65. <tr valign="top">
  66. <td nowrap><i>Copyright &copy; 2000</i></td>
  67. <td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
  68. Notre Dame (<a href=
  69. "mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
  70. </tr>
  71. </table>
  72. <p><i>Distributed under the Boost Software License, Version 1.0. (See
  73. accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  74. copy at <a href=
  75. "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
  76. </body>
  77. </html>