| 1 | <html> | 
|---|
| 2 | <head> | 
|---|
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | 
|---|
| 4 | <title>Concept ForwardIterator</title> | 
|---|
| 5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> | 
|---|
| 6 | <meta name="generator" content="DocBook XSL Stylesheets V1.68.1"> | 
|---|
| 7 | <link rel="start" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> | 
|---|
| 8 | <link rel="up" href="id620092-bb.html#concepts.reference" title="Concept reference"> | 
|---|
| 9 | <link rel="prev" href="OutputIterator.html" title="Concept OutputIterator"> | 
|---|
| 10 | <link rel="next" href="BidirectionalIterator.html" title="Concept BidirectionalIterator"> | 
|---|
| 11 | </head> | 
|---|
| 12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | 
|---|
| 13 | <table cellpadding="2" width="100%"> | 
|---|
| 14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td> | 
|---|
| 15 | <td align="center"><a href="../../index.htm">Home</a></td> | 
|---|
| 16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> | 
|---|
| 17 | <td align="center"><a href="../../people/people.htm">People</a></td> | 
|---|
| 18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> | 
|---|
| 19 | <td align="center"><a href="../../more/index.htm">More</a></td> | 
|---|
| 20 | </table> | 
|---|
| 21 | <hr> | 
|---|
| 22 | <div class="spirit-nav"> | 
|---|
| 23 | <a accesskey="p" href="OutputIterator.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="id620092-bb.html#concepts.reference"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="BidirectionalIterator.html"><img src="images/next.png" alt="Next"></a> | 
|---|
| 24 | </div> | 
|---|
| 25 | <div class="refentry" lang="en"> | 
|---|
| 26 | <a name="ForwardIterator"></a><div class="titlepage"></div> | 
|---|
| 27 | <div class="refnamediv"> | 
|---|
| 28 | <h2><span class="refentrytitle">Concept ForwardIterator</span></h2> | 
|---|
| 29 | <p>ForwardIterator</p> | 
|---|
| 30 | </div> | 
|---|
| 31 | <div class="refsect1" lang="en"> | 
|---|
| 32 | <a name="id943468"></a><h2>Description</h2> | 
|---|
| 33 | <p>A forward iterator is an iterator that can read through a sequence of | 
|---|
| 34 |   values.  It is multi-pass (old values of the iterator can be | 
|---|
| 35 |   re-used), and can be either mutable (data pointed to by it can be | 
|---|
| 36 |   changed) or not mutable.</p> | 
|---|
| 37 | <p>An iterator represents a position in a sequence.  Therefore, the | 
|---|
| 38 |   iterator can point into the sequence (returning a value when dereferenced | 
|---|
| 39 |   and being incrementable), or be off-the-end (and not dereferenceable or | 
|---|
| 40 |   incrementable).</p> | 
|---|
| 41 | </div> | 
|---|
| 42 | <div class="refsect1" lang="en"> | 
|---|
| 43 | <a name="id943487"></a><h2>Refinement of</h2> | 
|---|
| 44 | <div class="itemizedlist"><ul type="disc"> | 
|---|
| 45 | <li><p><a href="InputIterator.html" title="Concept InputIterator">InputIterator</a></p></li> | 
|---|
| 46 | <li><p><a href="OutputIterator.html" title="Concept OutputIterator">OutputIterator</a></p></li> | 
|---|
| 47 | </ul></div> | 
|---|
| 48 | </div> | 
|---|
| 49 | <div class="refsect1" lang="en"> | 
|---|
| 50 | <a name="id943507"></a><h2>Associated types</h2> | 
|---|
| 51 | <div class="itemizedlist"><ul type="disc"> | 
|---|
| 52 | <li> | 
|---|
| 53 | <p><span class="bold"><strong>value_type</strong></span></p> | 
|---|
| 54 | <pre class="literallayout">std::iterator_traits<Iter>::value_type</pre> | 
|---|
| 55 | <p>The value type of the iterator</p> | 
|---|
| 56 | </li> | 
|---|
| 57 | <li> | 
|---|
| 58 | <p><span class="bold"><strong>category</strong></span></p> | 
|---|
| 59 | <pre class="literallayout">std::iterator_traits<Iter>::iterator_category</pre> | 
|---|
| 60 | <p>The category of the iterator</p> | 
|---|
| 61 | </li> | 
|---|
| 62 | </ul></div> | 
|---|
| 63 | </div> | 
|---|
| 64 | <div class="refsect1" lang="en"> | 
|---|
| 65 | <a name="id943547"></a><h2>Notation</h2> | 
|---|
| 66 | <div class="variablelist"><dl> | 
|---|
| 67 | <dt><span class="term">Iter</span></dt> | 
|---|
| 68 | <dd>A type playing the role of iterator-type in the <a href="ForwardIterator.html" title="Concept ForwardIterator">ForwardIterator</a> concept.</dd> | 
|---|
| 69 | <dt> | 
|---|
| 70 | <span class="term"><code class="varname">i</code>, </span><span class="term"><code class="varname">j</code></span> | 
|---|
| 71 | </dt> | 
|---|
| 72 | <dd>Objects of type Iter</dd> | 
|---|
| 73 | <dt><span class="term"><code class="varname">x</code></span></dt> | 
|---|
| 74 | <dd>Object of type value_type</dd> | 
|---|
| 75 | </dl></div> | 
|---|
| 76 | </div> | 
|---|
| 77 | <div class="refsect1" lang="en"> | 
|---|
| 78 | <a name="id943585"></a><h2>Type expressions</h2> | 
|---|
| 79 | <div class="variablelist"><dl> | 
|---|
| 80 | <dt><span class="term">Category tag</span></dt> | 
|---|
| 81 | <dd><p><span class="type">category</span> must be  | 
|---|
| 82 |                   derived from <span class="type">std::forward_iterator_tag</span>. | 
|---|
| 83 |                 </p></dd> | 
|---|
| 84 | </dl></div> | 
|---|
| 85 | </div> | 
|---|
| 86 | <div class="refsect1" lang="en"> | 
|---|
| 87 | <a name="id943604"></a><h2>Valid expressions</h2> | 
|---|
| 88 | <div class="informaltable"><table class="table"> | 
|---|
| 89 | <colgroup> | 
|---|
| 90 | <col> | 
|---|
| 91 | <col> | 
|---|
| 92 | <col> | 
|---|
| 93 | <col> | 
|---|
| 94 | <col> | 
|---|
| 95 | <col> | 
|---|
| 96 | </colgroup> | 
|---|
| 97 | <thead><tr> | 
|---|
| 98 | <th>Name</th> | 
|---|
| 99 | <th>Expression</th> | 
|---|
| 100 | <th>Type</th> | 
|---|
| 101 | <th>Precondition</th> | 
|---|
| 102 | <th>Semantics</th> | 
|---|
| 103 | <th>Postcondition</th> | 
|---|
| 104 | </tr></thead> | 
|---|
| 105 | <tbody> | 
|---|
| 106 | <tr> | 
|---|
| 107 | <td><p>Dereference</p></td> | 
|---|
| 108 | <td><p>*i</p></td> | 
|---|
| 109 | <td><p><span class="type">const-if-not-mutable value_type &</span></p></td> | 
|---|
| 110 | <td><p><code class="computeroutput">i</code> is incrementable (not | 
|---|
| 111 |     off-the-end)</p></td> | 
|---|
| 112 | <td> </td> | 
|---|
| 113 | <td> </td> | 
|---|
| 114 | </tr> | 
|---|
| 115 | <tr> | 
|---|
| 116 | <td><p>Member access</p></td> | 
|---|
| 117 | <td><p>i->{member-name} (return type is pointer-to-object type)</p></td> | 
|---|
| 118 | <td><p><span class="type">const-if-not-mutable value_type *</span></p></td> | 
|---|
| 119 | <td><p><code class="computeroutput">i</code> is incrementable (not | 
|---|
| 120 |     off-the-end)</p></td> | 
|---|
| 121 | <td> </td> | 
|---|
| 122 | <td> </td> | 
|---|
| 123 | </tr> | 
|---|
| 124 | <tr> | 
|---|
| 125 | <td><p>Preincrement</p></td> | 
|---|
| 126 | <td><p>++i</p></td> | 
|---|
| 127 | <td><p><span class="type">Iter &</span></p></td> | 
|---|
| 128 | <td><p><code class="computeroutput">i</code> is incrementable (not | 
|---|
| 129 |     off-the-end)</p></td> | 
|---|
| 130 | <td> </td> | 
|---|
| 131 | <td> </td> | 
|---|
| 132 | </tr> | 
|---|
| 133 | <tr> | 
|---|
| 134 | <td><p>Postincrement</p></td> | 
|---|
| 135 | <td><p>i++</p></td> | 
|---|
| 136 | <td><p><span class="type">Iter</span></p></td> | 
|---|
| 137 | <td><p><code class="computeroutput">i</code> is incrementable (not | 
|---|
| 138 |     off-the-end)</p></td> | 
|---|
| 139 | <td><p>Equivalent to <code class="computeroutput">{Iter j = i; ++i; return j;}</code></p></td> | 
|---|
| 140 | <td><p><code class="computeroutput">i</code> is dereferenceable or | 
|---|
| 141 |     off-the-end</p></td> | 
|---|
| 142 | </tr> | 
|---|
| 143 | </tbody> | 
|---|
| 144 | </table></div> | 
|---|
| 145 | </div> | 
|---|
| 146 | <div class="refsect1" lang="en"> | 
|---|
| 147 | <a name="id961214"></a><h2>Complexity</h2> | 
|---|
| 148 | <p> | 
|---|
| 149 |   All iterator operations must take amortized constant time. | 
|---|
| 150 |   </p> | 
|---|
| 151 | </div> | 
|---|
| 152 | <div class="refsect1" lang="en"> | 
|---|
| 153 | <a name="id961221"></a><h2>Invariants</h2> | 
|---|
| 154 | <div class="variablelist"><dl> | 
|---|
| 155 | <dt><span class="term">Predecrement must return object</span></dt> | 
|---|
| 156 | <dd><p> | 
|---|
| 157 |   <code class="computeroutput">&i = &(++i)</code> | 
|---|
| 158 |   </p></dd> | 
|---|
| 159 | <dt><span class="term">Unique path through sequence</span></dt> | 
|---|
| 160 | <dd><p> | 
|---|
| 161 |   <code class="computeroutput">i == j</code> implies <code class="computeroutput">++i == ++j</code> | 
|---|
| 162 |   </p></dd> | 
|---|
| 163 | </dl></div> | 
|---|
| 164 | </div> | 
|---|
| 165 | <div class="refsect1" lang="en"> | 
|---|
| 166 | <a name="id961257"></a><h2>Models</h2> | 
|---|
| 167 | <div class="itemizedlist"><ul type="disc"> | 
|---|
| 168 | <li><span class="simplelist"><span class="type">T *</span></span></li> | 
|---|
| 169 | <li><span class="simplelist"><span class="type">std::hash_set<T>::iterator</span></span></li> | 
|---|
| 170 | </ul></div> | 
|---|
| 171 | </div> | 
|---|
| 172 | <div class="refsect1" lang="en"> | 
|---|
| 173 | <a name="id961277"></a><h2>See also</h2> | 
|---|
| 174 | <div class="itemizedlist"><ul type="disc"><li><p><a href="BidirectionalIterator.html" title="Concept BidirectionalIterator">BidirectionalIterator</a></p></li></ul></div> | 
|---|
| 175 | </div> | 
|---|
| 176 | </div> | 
|---|
| 177 | <table width="100%"><tr> | 
|---|
| 178 | <td align="left"></td> | 
|---|
| 179 | <td align="right"><small>Copyright © 2001, 2002 Indiana University<br>Copyright © 2000, 2001 University of Notre Dame du Lac<br>Copyright © 2000 Jeremy Siek, Lie-Quan Lee, Andrew Lumsdaine<br>Copyright © 1996-1999 Silicon Graphics Computer Systems, Inc.<br>Copyright © 1994 Hewlett-Packard Company</small></td> | 
|---|
| 180 | </tr></table> | 
|---|
| 181 | <hr> | 
|---|
| 182 | <div class="spirit-nav"> | 
|---|
| 183 | <a accesskey="p" href="OutputIterator.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="id620092-bb.html#concepts.reference"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="BidirectionalIterator.html"><img src="images/next.png" alt="Next"></a> | 
|---|
| 184 | </div> | 
|---|
| 185 | </body> | 
|---|
| 186 | </html> | 
|---|