forked from boostorg/iterator
filled out some missing operator--, added a comment about the operations and concepts,
and added some text to the indirect iterator example [SVN r21629]
This commit is contained in:
@ -45,12 +45,15 @@ adding an <tt class="literal"><span class="pre">operator*</span></tt> that retur
|
||||
<div class="contents topic" id="table-of-contents">
|
||||
<p class="topic-title"><a name="table-of-contents">Table of Contents</a></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#counting-iterator-requirements" id="id1" name="id1"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-models" id="id2" name="id2"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-operations" id="id3" name="id3"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#example" id="id4" name="id4">Example</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-synopsis" id="id1" name="id1"><tt class="literal"><span class="pre">counting_iterator</span></tt> synopsis</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-requirements" id="id2" name="id2"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-models" id="id3" name="id3"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-operations" id="id4" name="id4"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#example" id="id5" name="id5">Example</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-synopsis">
|
||||
<h1><a class="toc-backref" href="#id1" name="counting-iterator-synopsis"><tt class="literal"><span class="pre">counting_iterator</span></tt> synopsis</a></h1>
|
||||
<pre class="literal-block">
|
||||
template <
|
||||
class Incrementable
|
||||
@ -64,8 +67,11 @@ class counting_iterator
|
||||
counting_iterator(counting_iterator const& rhs);
|
||||
explicit counting_iterator(Incrementable x);
|
||||
Incrementable base() const;
|
||||
reference operator*() const;
|
||||
counting_iterator& operator++();
|
||||
counting_iterator& operator--();
|
||||
private:
|
||||
Incrementable current; // exposition
|
||||
Incrementable m_inc; // exposition
|
||||
};
|
||||
</pre>
|
||||
<dl>
|
||||
@ -73,14 +79,15 @@ class counting_iterator
|
||||
<dd><tt class="literal"><span class="pre">distance_to</span></tt> and a <tt class="literal"><span class="pre">difference_type</span></tt> that avoids overflows in
|
||||
the cases when the <tt class="literal"><span class="pre">Incrementable</span></tt> type is a numeric type.]</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-requirements">
|
||||
<h1><a class="toc-backref" href="#id1" name="counting-iterator-requirements"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></h1>
|
||||
<h1><a class="toc-backref" href="#id2" name="counting-iterator-requirements"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></h1>
|
||||
<p>The <tt class="literal"><span class="pre">Incrementable</span></tt> type must be Default Constructible, Copy
|
||||
Constructible, and Assignable. The default distance is
|
||||
an implementation defined signed integral type.</p>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-models">
|
||||
<h1><a class="toc-backref" href="#id2" name="counting-iterator-models"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></h1>
|
||||
<h1><a class="toc-backref" href="#id3" name="counting-iterator-models"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></h1>
|
||||
<p><tt class="literal"><span class="pre">counting_iterator</span></tt> models Readable Lvalue Iterator.</p>
|
||||
<p>Furthermore, if you wish to create a counting iterator that is a Forward
|
||||
Traversal Iterator, then the following expressions must be valid:</p>
|
||||
@ -105,7 +112,10 @@ i < j
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-operations">
|
||||
<h1><a class="toc-backref" href="#id3" name="counting-iterator-operations"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></h1>
|
||||
<h1><a class="toc-backref" href="#id4" name="counting-iterator-operations"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></h1>
|
||||
<p>In addition to the operations required by the concepts modeled by
|
||||
<tt class="literal"><span class="pre">counting_iterator</span></tt>, <tt class="literal"><span class="pre">counting_iterator</span></tt> provides the following
|
||||
operations.</p>
|
||||
<p><tt class="literal"><span class="pre">counting_iterator();</span></tt></p>
|
||||
<table class="field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@ -129,7 +139,7 @@ i < j
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">counting_iterator</span></tt> with <tt class="literal"><span class="pre">current</span></tt>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body">An instance of <tt class="literal"><span class="pre">counting_iterator</span></tt> with <tt class="literal"><span class="pre">m_inc</span></tt>
|
||||
constructed from <tt class="literal"><span class="pre">x</span></tt>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -139,7 +149,7 @@ constructed from <tt class="literal"><span class="pre">x</span></tt>.</td>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">current</span></tt></td>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">m_inc</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -148,7 +158,20 @@ constructed from <tt class="literal"><span class="pre">x</span></tt>.</td>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Effects:</th><td class="field-body"><tt class="literal"><span class="pre">++current</span></tt></td>
|
||||
<tr class="field"><th class="field-name">Effects:</th><td class="field-body"><tt class="literal"><span class="pre">++m_inc</span></tt></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">*this</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><tt class="literal"><span class="pre">counting_iterator&</span> <span class="pre">operator--();</span></tt></p>
|
||||
<table class="field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Effects:</th><td class="field-body"><tt class="literal"><span class="pre">--m_inc</span></tt></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">*this</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -157,7 +180,7 @@ constructed from <tt class="literal"><span class="pre">x</span></tt>.</td>
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">current</span></tt></td>
|
||||
<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><tt class="literal"><span class="pre">m_inc</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -176,7 +199,7 @@ with <tt class="literal"><span class="pre">current</span></tt> constructed from
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="example">
|
||||
<h1><a class="toc-backref" href="#id4" name="example">Example</a></h1>
|
||||
<h1><a class="toc-backref" href="#id5" name="example">Example</a></h1>
|
||||
<p>This example fills an array with numbers and a second array with
|
||||
pointers into the first array, using <tt class="literal"><span class="pre">counting_iterator</span></tt> for both
|
||||
tasks. Finally <tt class="literal"><span class="pre">indirect_iterator</span></tt> is used to print out the numbers
|
||||
@ -211,7 +234,7 @@ indirectly printing out the numbers from 0 to 7
|
||||
<hr class="footer"/>
|
||||
<div class="footer">
|
||||
<a class="reference" href="counting_iterator.rst">View document source</a>.
|
||||
Generated on: 2004-01-12 15:20 UTC.
|
||||
Generated on: 2004-01-12 15:46 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
</div>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user