forked from boostorg/iterator
Applied use of iterator-category to specialized adapters
[SVN r21745]
This commit is contained in:
1 parent
33f630beca
commit
c3fd7076c1
11 files changed
+290
-253
No files matched your search
+18
-14
@@ -89,21 +89,25 @@ class counting_iterator
|
||||
Incrementable m_inc; // exposition
|
||||
};
|
||||
</pre>
|
||||
<p>If the <tt class="literal"><span class="pre">Difference</span></tt> argument is <tt class="literal"><span class="pre">use_default</span></tt> then the
|
||||
<tt class="literal"><span class="pre">difference_type</span></tt> member is an unspecified signed integral
|
||||
<p>If the <tt class="literal"><span class="pre">Difference</span></tt> argument is <tt class="literal"><span class="pre">use_default</span></tt> then
|
||||
<tt class="literal"><span class="pre">difference_type</span></tt> is an unspecified signed integral
|
||||
type. Otherwise <tt class="literal"><span class="pre">difference_type</span></tt> is <tt class="literal"><span class="pre">Difference</span></tt>.</p>
|
||||
<p>If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is not <tt class="literal"><span class="pre">use_default</span></tt> then the member
|
||||
<tt class="literal"><span class="pre">iterator_category</span></tt> is <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>. Otherwise, if
|
||||
<tt class="literal"><span class="pre">numeric_limits<Incrementable>::is_specialized</span></tt>, then
|
||||
<tt class="literal"><span class="pre">iterator_category</span></tt> is a
|
||||
<tt class="literal"><span class="pre">facade_iterator_category(random_access_traversal_tag,</span> <span class="pre">Incrementable,</span> <span class="pre">const</span> <span class="pre">Incrementable&)</span></tt>.
|
||||
Otherwise, <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
<tt class="literal"><span class="pre">facade_iterator_category(iterator_traversal<Incrementable>::type,</span> <span class="pre">Incrementable,</span> <span class="pre">const</span> <span class="pre">Incrementable&)</span></tt>.</p>
|
||||
<dl>
|
||||
<dt>[<em>Note:</em> implementers are encouraged to provide an implementation of</dt>
|
||||
<dd><tt class="literal"><span class="pre">operator-</span></tt> and the default <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>
|
||||
<p><tt class="literal"><span class="pre">iterator_category</span></tt> is determined according to the following
|
||||
algorithm:</p>
|
||||
<pre class="literal-block">
|
||||
if (CategoryOrTraversal is not use_default)
|
||||
return CategoryOrTraversal
|
||||
else if (numeric_limits<Incrementable>::is_specialized)
|
||||
return <a class="reference" href="iterator_facade.html#iterator-category"><em>iterator-category</em></a>(
|
||||
random_access_traversal_tag, Incrementable, const Incrementable&)
|
||||
else
|
||||
return <a class="reference" href="iterator_facade.html#iterator-category"><em>iterator-category</em></a>(
|
||||
iterator_traversal<Incrementable>::type,
|
||||
Incrementable, const Incrementable&)
|
||||
</pre>
|
||||
<p>[<em>Note:</em> implementers are encouraged to provide an implementation
|
||||
of <tt class="literal"><span class="pre">operator-</span></tt> and a default <tt class="literal"><span class="pre">difference_type</span></tt> that avoid
|
||||
overflows when <tt class="literal"><span class="pre">Incrementable</span></tt> is a numeric type.]</p>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-requirements">
|
||||
<h1><a class="toc-backref" href="#id3" name="counting-iterator-requirements"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></h1>
|
||||
|
||||
@@ -34,3 +34,6 @@
|
||||
.. include:: make_counting_iterator.rst
|
||||
|
||||
.. include:: counting_iterator_eg.rst
|
||||
|
||||
.. _iterator-category: iterator_facade.html#iterator-category
|
||||
.. |iterator-category| replace:: *iterator-category*
|
||||
@@ -26,22 +26,28 @@
|
||||
};
|
||||
|
||||
|
||||
If the ``Difference`` argument is ``use_default`` then the
|
||||
``difference_type`` member is an unspecified signed integral
|
||||
If the ``Difference`` argument is ``use_default`` then
|
||||
``difference_type`` is an unspecified signed integral
|
||||
type. Otherwise ``difference_type`` is ``Difference``.
|
||||
|
||||
If ``CategoryOrTraversal`` is not ``use_default`` then the member
|
||||
``iterator_category`` is ``CategoryOrTraversal``. Otherwise, if
|
||||
``numeric_limits<Incrementable>::is_specialized``, then
|
||||
``iterator_category`` is a
|
||||
``facade_iterator_category(random_access_traversal_tag, Incrementable, const Incrementable&)``.
|
||||
Otherwise, ``iterator_category`` is
|
||||
``facade_iterator_category(iterator_traversal<Incrementable>::type, Incrementable, const Incrementable&)``.
|
||||
``iterator_category`` is determined according to the following
|
||||
algorithm:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
[*Note:* implementers are encouraged to provide an implementation of
|
||||
``operator-`` and the default ``difference_type`` that avoids overflows in
|
||||
the cases when the ``Incrementable`` type is a numeric type.]
|
||||
if (CategoryOrTraversal is not use_default)
|
||||
return CategoryOrTraversal
|
||||
else if (numeric_limits<Incrementable>::is_specialized)
|
||||
return |iterator-category|_\ (
|
||||
random_access_traversal_tag, Incrementable, const Incrementable&)
|
||||
else
|
||||
return |iterator-category|_\ (
|
||||
iterator_traversal<Incrementable>::type,
|
||||
Incrementable, const Incrementable&)
|
||||
|
||||
[*Note:* implementers are encouraged to provide an implementation
|
||||
of ``operator-`` and a default ``difference_type`` that avoid
|
||||
overflows when ``Incrementable`` is a numeric type.]
|
||||
|
||||
``counting_iterator`` requirements
|
||||
..................................
|
||||
|
||||
+151
-142
@@ -56,83 +56,83 @@ by adapting other iterators.</td>
|
||||
<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="#motivation" id="id13" name="id13">Motivation</a></li>
|
||||
<li><a class="reference" href="#impact-on-the-standard" id="id14" name="id14">Impact on the Standard</a></li>
|
||||
<li><a class="reference" href="#design" id="id15" name="id15">Design</a><ul>
|
||||
<li><a class="reference" href="#iterator-concepts" id="id16" name="id16">Iterator Concepts</a></li>
|
||||
<li><a class="reference" href="#interoperability" id="id17" name="id17">Interoperability</a></li>
|
||||
<li><a class="reference" href="#iterator-facade" id="id18" name="id18">Iterator Facade</a><ul>
|
||||
<li><a class="reference" href="#usage" id="id19" name="id19">Usage</a></li>
|
||||
<li><a class="reference" href="#iterator-core-access" id="id20" name="id20">Iterator Core Access</a></li>
|
||||
<li><a class="reference" href="#operator" id="id21" name="id21"><tt class="literal"><span class="pre">operator[]</span></tt></a></li>
|
||||
<li><a class="reference" href="#id6" id="id22" name="id22"><tt class="literal"><span class="pre">operator-></span></tt></a></li>
|
||||
<li><a class="reference" href="#motivation" id="id14" name="id14">Motivation</a></li>
|
||||
<li><a class="reference" href="#impact-on-the-standard" id="id15" name="id15">Impact on the Standard</a></li>
|
||||
<li><a class="reference" href="#design" id="id16" name="id16">Design</a><ul>
|
||||
<li><a class="reference" href="#iterator-concepts" id="id17" name="id17">Iterator Concepts</a></li>
|
||||
<li><a class="reference" href="#interoperability" id="id18" name="id18">Interoperability</a></li>
|
||||
<li><a class="reference" href="#iterator-facade" id="id19" name="id19">Iterator Facade</a><ul>
|
||||
<li><a class="reference" href="#usage" id="id20" name="id20">Usage</a></li>
|
||||
<li><a class="reference" href="#iterator-core-access" id="id21" name="id21">Iterator Core Access</a></li>
|
||||
<li><a class="reference" href="#operator" id="id22" name="id22"><tt class="literal"><span class="pre">operator[]</span></tt></a></li>
|
||||
<li><a class="reference" href="#id6" id="id23" name="id23"><tt class="literal"><span class="pre">operator-></span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#iterator-adaptor" id="id23" name="id23">Iterator Adaptor</a></li>
|
||||
<li><a class="reference" href="#specialized-adaptors" id="id24" name="id24">Specialized Adaptors</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor" id="id24" name="id24">Iterator Adaptor</a></li>
|
||||
<li><a class="reference" href="#specialized-adaptors" id="id25" name="id25">Specialized Adaptors</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#proposed-text" id="id25" name="id25">Proposed Text</a><ul>
|
||||
<li><a class="reference" href="#header-iterator-helper-synopsis-lib-iterator-helper-synopsis" id="id26" name="id26">Header <tt class="literal"><span class="pre"><iterator_helper></span></tt> synopsis [lib.iterator.helper.synopsis]</a></li>
|
||||
<li><a class="reference" href="#iterator-facade-lib-iterator-facade" id="id27" name="id27">Iterator facade [lib.iterator.facade]</a><ul>
|
||||
<li><a class="reference" href="#class-template-iterator-facade" id="id28" name="id28">Class template <tt class="literal"><span class="pre">iterator_facade</span></tt></a></li>
|
||||
<li><a class="reference" href="#iterator-facade-requirements" id="id29" name="id29"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></li>
|
||||
<li><a class="reference" href="#iterator-facade-operations" id="id30" name="id30"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#proposed-text" id="id26" name="id26">Proposed Text</a><ul>
|
||||
<li><a class="reference" href="#header-iterator-helper-synopsis-lib-iterator-helper-synopsis" id="id27" name="id27">Header <tt class="literal"><span class="pre"><iterator_helper></span></tt> synopsis [lib.iterator.helper.synopsis]</a></li>
|
||||
<li><a class="reference" href="#iterator-facade-lib-iterator-facade" id="id28" name="id28">Iterator facade [lib.iterator.facade]</a><ul>
|
||||
<li><a class="reference" href="#class-template-iterator-facade" id="id29" name="id29">Class template <tt class="literal"><span class="pre">iterator_facade</span></tt></a></li>
|
||||
<li><a class="reference" href="#iterator-facade-requirements" id="id30" name="id30"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></li>
|
||||
<li><a class="reference" href="#iterator-facade-operations" id="id31" name="id31"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#iterator-adaptor-lib-iterator-adaptor" id="id31" name="id31">Iterator adaptor [lib.iterator.adaptor]</a><ul>
|
||||
<li><a class="reference" href="#class-template-iterator-adaptor" id="id32" name="id32">Class template <tt class="literal"><span class="pre">iterator_adaptor</span></tt></a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-requirements" id="id33" name="id33"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-base-class-parameters" id="id34" name="id34"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> base class parameters</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-models" id="id35" name="id35"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-public-operations" id="id36" name="id36"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> public operations</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-protected-member-functions" id="id37" name="id37"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> protected member functions</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-private-member-functions" id="id38" name="id38"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> private member functions</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-lib-iterator-adaptor" id="id32" name="id32">Iterator adaptor [lib.iterator.adaptor]</a><ul>
|
||||
<li><a class="reference" href="#class-template-iterator-adaptor" id="id33" name="id33">Class template <tt class="literal"><span class="pre">iterator_adaptor</span></tt></a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-requirements" id="id34" name="id34"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-base-class-parameters" id="id35" name="id35"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> base class parameters</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-models" id="id36" name="id36"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-public-operations" id="id37" name="id37"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> public operations</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-protected-member-functions" id="id38" name="id38"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> protected member functions</a></li>
|
||||
<li><a class="reference" href="#iterator-adaptor-private-member-functions" id="id39" name="id39"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> private member functions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#specialized-adaptors-lib-iterator-special-adaptors" id="id39" name="id39">Specialized adaptors [lib.iterator.special.adaptors]</a><ul>
|
||||
<li><a class="reference" href="#indirect-iterator" id="id40" name="id40">Indirect iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-pointee" id="id41" name="id41">Class template <tt class="literal"><span class="pre">pointee</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-indirect-reference" id="id42" name="id42">Class template <tt class="literal"><span class="pre">indirect_reference</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-indirect-iterator" id="id43" name="id43">Class template <tt class="literal"><span class="pre">indirect_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#indirect-iterator-requirements" id="id44" name="id44"><tt class="literal"><span class="pre">indirect_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#indirect-iterator-models" id="id45" name="id45"><tt class="literal"><span class="pre">indirect_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#indirect-iterator-operations" id="id46" name="id46"><tt class="literal"><span class="pre">indirect_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#specialized-adaptors-lib-iterator-special-adaptors" id="id40" name="id40">Specialized adaptors [lib.iterator.special.adaptors]</a><ul>
|
||||
<li><a class="reference" href="#indirect-iterator" id="id41" name="id41">Indirect iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-pointee" id="id42" name="id42">Class template <tt class="literal"><span class="pre">pointee</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-indirect-reference" id="id43" name="id43">Class template <tt class="literal"><span class="pre">indirect_reference</span></tt></a></li>
|
||||
<li><a class="reference" href="#class-template-indirect-iterator" id="id44" name="id44">Class template <tt class="literal"><span class="pre">indirect_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#indirect-iterator-requirements" id="id45" name="id45"><tt class="literal"><span class="pre">indirect_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#indirect-iterator-models" id="id46" name="id46"><tt class="literal"><span class="pre">indirect_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#indirect-iterator-operations" id="id47" name="id47"><tt class="literal"><span class="pre">indirect_iterator</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#reverse-iterator" id="id47" name="id47">Reverse iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-reverse-iterator" id="id48" name="id48">Class template <tt class="literal"><span class="pre">reverse_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#reverse-iterator-requirements" id="id49" name="id49"><tt class="literal"><span class="pre">reverse_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#reverse-iterator-models" id="id50" name="id50"><tt class="literal"><span class="pre">reverse_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#reverse-iterator-operations" id="id51" name="id51"><tt class="literal"><span class="pre">reverse_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#reverse-iterator" id="id48" name="id48">Reverse iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-reverse-iterator" id="id49" name="id49">Class template <tt class="literal"><span class="pre">reverse_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#reverse-iterator-requirements" id="id50" name="id50"><tt class="literal"><span class="pre">reverse_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#reverse-iterator-models" id="id51" name="id51"><tt class="literal"><span class="pre">reverse_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#reverse-iterator-operations" id="id52" name="id52"><tt class="literal"><span class="pre">reverse_iterator</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#transform-iterator" id="id52" name="id52">Transform iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-transform-iterator" id="id53" name="id53">Class template <tt class="literal"><span class="pre">transform_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#transform-iterator-requirements" id="id54" name="id54"><tt class="literal"><span class="pre">transform_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#transform-iterator-models" id="id55" name="id55"><tt class="literal"><span class="pre">transform_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#transform-iterator-operations" id="id56" name="id56"><tt class="literal"><span class="pre">transform_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#transform-iterator" id="id53" name="id53">Transform iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-transform-iterator" id="id54" name="id54">Class template <tt class="literal"><span class="pre">transform_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#transform-iterator-requirements" id="id55" name="id55"><tt class="literal"><span class="pre">transform_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#transform-iterator-models" id="id56" name="id56"><tt class="literal"><span class="pre">transform_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#transform-iterator-operations" id="id57" name="id57"><tt class="literal"><span class="pre">transform_iterator</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#filter-iterator" id="id57" name="id57">Filter iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-filter-iterator" id="id58" name="id58">Class template <tt class="literal"><span class="pre">filter_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#filter-iterator-requirements" id="id59" name="id59"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-models" id="id60" name="id60"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-operations" id="id61" name="id61"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#filter-iterator" id="id58" name="id58">Filter iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-filter-iterator" id="id59" name="id59">Class template <tt class="literal"><span class="pre">filter_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#filter-iterator-requirements" id="id60" name="id60"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-models" id="id61" name="id61"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#filter-iterator-operations" id="id62" name="id62"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#counting-iterator" id="id62" name="id62">Counting iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-counting-iterator" id="id63" name="id63">Class template <tt class="literal"><span class="pre">counting_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#counting-iterator-requirements" id="id64" name="id64"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-models" id="id65" name="id65"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-operations" id="id66" name="id66"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#counting-iterator" id="id63" name="id63">Counting iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-counting-iterator" id="id64" name="id64">Class template <tt class="literal"><span class="pre">counting_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#counting-iterator-requirements" id="id65" name="id65"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-models" id="id66" name="id66"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#counting-iterator-operations" id="id67" name="id67"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#function-output-iterator" id="id67" name="id67">Function output iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-function-output-iterator" id="id68" name="id68">Class template <tt class="literal"><span class="pre">function_output_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#function-output-iterator-requirements" id="id69" name="id69"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#function-output-iterator-models" id="id70" name="id70"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#function-output-iterator-operations" id="id71" name="id71"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#function-output-iterator" id="id68" name="id68">Function output iterator</a><ul>
|
||||
<li><a class="reference" href="#class-template-function-output-iterator" id="id69" name="id69">Class template <tt class="literal"><span class="pre">function_output_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#function-output-iterator-requirements" id="id70" name="id70"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></li>
|
||||
<li><a class="reference" href="#function-output-iterator-models" id="id71" name="id71"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></li>
|
||||
<li><a class="reference" href="#function-output-iterator-operations" id="id72" name="id72"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -142,7 +142,7 @@ by adapting other iterators.</td>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="motivation">
|
||||
<h1><a class="toc-backref" href="#id13" name="motivation">Motivation</a></h1>
|
||||
<h1><a class="toc-backref" href="#id14" name="motivation">Motivation</a></h1>
|
||||
<p>Iterators play an important role in modern C++ programming. The
|
||||
iterator is the central abstraction of the algorithms of the Standard
|
||||
Library, allowing algorithms to be re-used in in a wide variety of
|
||||
@@ -227,15 +227,15 @@ applies some user-specified function during the dereference of the
|
||||
iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="impact-on-the-standard">
|
||||
<h1><a class="toc-backref" href="#id14" name="impact-on-the-standard">Impact on the Standard</a></h1>
|
||||
<h1><a class="toc-backref" href="#id15" name="impact-on-the-standard">Impact on the Standard</a></h1>
|
||||
<p>This proposal is purely an addition to the C++ standard library.
|
||||
However, note that this proposal relies on the proposal for New
|
||||
Iterator Concepts.</p>
|
||||
</div>
|
||||
<div class="section" id="design">
|
||||
<h1><a class="toc-backref" href="#id15" name="design">Design</a></h1>
|
||||
<h1><a class="toc-backref" href="#id16" name="design">Design</a></h1>
|
||||
<div class="section" id="iterator-concepts">
|
||||
<h2><a class="toc-backref" href="#id16" name="iterator-concepts">Iterator Concepts</a></h2>
|
||||
<h2><a class="toc-backref" href="#id17" name="iterator-concepts">Iterator Concepts</a></h2>
|
||||
<p>This proposal is formulated in terms of the new <tt class="literal"><span class="pre">iterator</span> <span class="pre">concepts</span></tt>
|
||||
as proposed in <a class="reference" href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/papers/2003/n1550.html">n1550</a>, since user-defined and especially adapted
|
||||
iterators suffer from the well known categorization problems that are
|
||||
@@ -245,7 +245,7 @@ is a direct mapping between new and old categories. This proposal
|
||||
could be reformulated using this mapping if <a class="reference" href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/papers/2003/n1550.html">n1550</a> was not accepted.</p>
|
||||
</div>
|
||||
<div class="section" id="interoperability">
|
||||
<h2><a class="toc-backref" href="#id17" name="interoperability">Interoperability</a></h2>
|
||||
<h2><a class="toc-backref" href="#id18" name="interoperability">Interoperability</a></h2>
|
||||
<p>The question of iterator interoperability is poorly addressed in the
|
||||
current standard. There are currently two defect reports that are
|
||||
concerned with interoperability issues.</p>
|
||||
@@ -265,7 +265,7 @@ fixes the issues raised in 280. It provides the desired
|
||||
interoperability without introducing unwanted overloads.</p>
|
||||
</div>
|
||||
<div class="section" id="iterator-facade">
|
||||
<h2><a class="toc-backref" href="#id18" name="iterator-facade">Iterator Facade</a></h2>
|
||||
<h2><a class="toc-backref" href="#id19" name="iterator-facade">Iterator Facade</a></h2>
|
||||
<!-- Version 1.1 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG for TR1. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -310,7 +310,7 @@ impossible.</li>
|
||||
</ol>
|
||||
</blockquote>
|
||||
<div class="section" id="usage">
|
||||
<h3><a class="toc-backref" href="#id19" name="usage">Usage</a></h3>
|
||||
<h3><a class="toc-backref" href="#id20" name="usage">Usage</a></h3>
|
||||
<p>The user of <tt class="literal"><span class="pre">iterator_facade</span></tt> derives his iterator class from a
|
||||
specialization of <tt class="literal"><span class="pre">iterator_facade</span></tt> and passes the derived
|
||||
iterator class as <tt class="literal"><span class="pre">iterator_facade</span></tt>'s first template parameter.
|
||||
@@ -374,7 +374,7 @@ Iterator or a more-refined iterator concept, a default constructor is
|
||||
required.</p>
|
||||
</div>
|
||||
<div class="section" id="iterator-core-access">
|
||||
<h3><a class="toc-backref" href="#id20" name="iterator-core-access">Iterator Core Access</a></h3>
|
||||
<h3><a class="toc-backref" href="#id21" name="iterator-core-access">Iterator Core Access</a></h3>
|
||||
<p><tt class="literal"><span class="pre">iterator_facade</span></tt> and the operator implementations need to be able
|
||||
to access the core member functions in the derived class. Making the
|
||||
core member functions public would expose an implementation detail to
|
||||
@@ -408,7 +408,7 @@ open a safety loophole, as every core member function preserves the
|
||||
invariants of the iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="operator">
|
||||
<h3><a class="toc-backref" href="#id21" name="operator"><tt class="literal"><span class="pre">operator[]</span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id22" name="operator"><tt class="literal"><span class="pre">operator[]</span></tt></a></h3>
|
||||
<p>The indexing operator for a generalized iterator presents special
|
||||
challenges. A random access iterator's <tt class="literal"><span class="pre">operator[]</span></tt> is only
|
||||
required to return something convertible to its <tt class="literal"><span class="pre">value_type</span></tt>.
|
||||
@@ -431,7 +431,7 @@ class; it will hide the one supplied by <tt class="literal"><span class="pre">it
|
||||
clients of her iterator.</p>
|
||||
<a class="target" id="operator-arrow" name="operator-arrow"></a></div>
|
||||
<div class="section" id="id6">
|
||||
<h3><a class="toc-backref" href="#id22" name="id6"><tt class="literal"><span class="pre">operator-></span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id23" name="id6"><tt class="literal"><span class="pre">operator-></span></tt></a></h3>
|
||||
<p>The <tt class="literal"><span class="pre">reference</span></tt> type of a readable iterator (and today's input
|
||||
iterator) need not in fact be a reference, so long as it is
|
||||
convertible to the iterator's <tt class="literal"><span class="pre">value_type</span></tt>. When the <tt class="literal"><span class="pre">value_type</span></tt>
|
||||
@@ -454,7 +454,7 @@ Patterns, C++ Report, February 1995, pp. 24-27.</td></tr>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="iterator-adaptor">
|
||||
<h2><a class="toc-backref" href="#id23" name="iterator-adaptor">Iterator Adaptor</a></h2>
|
||||
<h2><a class="toc-backref" href="#id24" name="iterator-adaptor">Iterator Adaptor</a></h2>
|
||||
<!-- Version 1.2 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG for TR1. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -495,7 +495,7 @@ template parameter may not always be identical to the iterator's
|
||||
that assumption.</p>
|
||||
</div>
|
||||
<div class="section" id="specialized-adaptors">
|
||||
<h2><a class="toc-backref" href="#id24" name="specialized-adaptors">Specialized Adaptors</a></h2>
|
||||
<h2><a class="toc-backref" href="#id25" name="specialized-adaptors">Specialized Adaptors</a></h2>
|
||||
<p>This proposal also contains several examples of specialized adaptors
|
||||
which were easily implemented using <tt class="literal"><span class="pre">iterator_adaptor</span></tt>:</p>
|
||||
<ul class="simple">
|
||||
@@ -532,9 +532,9 @@ Standard compliant iterators).</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="proposed-text">
|
||||
<h1><a class="toc-backref" href="#id25" name="proposed-text">Proposed Text</a></h1>
|
||||
<h1><a class="toc-backref" href="#id26" name="proposed-text">Proposed Text</a></h1>
|
||||
<div class="section" id="header-iterator-helper-synopsis-lib-iterator-helper-synopsis">
|
||||
<h2><a class="toc-backref" href="#id26" name="header-iterator-helper-synopsis-lib-iterator-helper-synopsis">Header <tt class="literal"><span class="pre"><iterator_helper></span></tt> synopsis [lib.iterator.helper.synopsis]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id27" name="header-iterator-helper-synopsis-lib-iterator-helper-synopsis">Header <tt class="literal"><span class="pre"><iterator_helper></span></tt> synopsis [lib.iterator.helper.synopsis]</a></h2>
|
||||
<pre class="literal-block">
|
||||
struct use_default;
|
||||
|
||||
@@ -600,12 +600,12 @@ class function_output_iterator;
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="iterator-facade-lib-iterator-facade">
|
||||
<h2><a class="toc-backref" href="#id27" name="iterator-facade-lib-iterator-facade">Iterator facade [lib.iterator.facade]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id28" name="iterator-facade-lib-iterator-facade">Iterator facade [lib.iterator.facade]</a></h2>
|
||||
<p><tt class="literal"><span class="pre">iterator_facade</span></tt> is a base class template that implements the
|
||||
interface of standard iterators in terms of a few core functions
|
||||
and associated types, to be supplied by a derived iterator class.</p>
|
||||
<div class="section" id="class-template-iterator-facade">
|
||||
<h3><a class="toc-backref" href="#id28" name="class-template-iterator-facade">Class template <tt class="literal"><span class="pre">iterator_facade</span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id29" name="class-template-iterator-facade">Class template <tt class="literal"><span class="pre">iterator_facade</span></tt></a></h3>
|
||||
<!-- Version 1.3 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG for TR1. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -698,7 +698,7 @@ Derived operator+ (iterator_facade<Derived, V, TC, R, D> const&,
|
||||
<em>iterator-category</em>(CategoryOrTraversal, value_type, reference)
|
||||
</pre>
|
||||
<p>where <em>iterator-category</em> is defined as follows:</p>
|
||||
<pre class="literal-block">
|
||||
<a class="target" id="id11" name="id11"></a><pre class="literal-block">
|
||||
<em>iterator-category</em>(C,R,V) :=
|
||||
if (C is convertible to std::input_iterator_tag
|
||||
|| C is convertible to std::output_iterator_tag
|
||||
@@ -776,7 +776,7 @@ struct enable_if_interoperable
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="iterator-facade-requirements">
|
||||
<h3><a class="toc-backref" href="#id29" name="iterator-facade-requirements"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></h3>
|
||||
<h3><a class="toc-backref" href="#id30" name="iterator-facade-requirements"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></h3>
|
||||
<p>The following table describes the typical valid expressions on
|
||||
<tt class="literal"><span class="pre">iterator_facade</span></tt>'s <tt class="literal"><span class="pre">Derived</span></tt> parameter, depending on the
|
||||
iterator concept(s) it will model. The operations in the first
|
||||
@@ -847,7 +847,7 @@ Iterator</td>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="iterator-facade-operations">
|
||||
<h3><a class="toc-backref" href="#id30" name="iterator-facade-operations"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></h3>
|
||||
<h3><a class="toc-backref" href="#id31" name="iterator-facade-operations"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></h3>
|
||||
<p>The operations in this section are described in terms of operations on
|
||||
the core interface of <tt class="literal"><span class="pre">Derived</span></tt> which may be inaccessible
|
||||
(i.e. private). The implementation should access these operations
|
||||
@@ -988,7 +988,7 @@ return tmp -= n;
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="iterator-adaptor-lib-iterator-adaptor">
|
||||
<h2><a class="toc-backref" href="#id31" name="iterator-adaptor-lib-iterator-adaptor">Iterator adaptor [lib.iterator.adaptor]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id32" name="iterator-adaptor-lib-iterator-adaptor">Iterator adaptor [lib.iterator.adaptor]</a></h2>
|
||||
<!-- Version 1.1 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -1004,7 +1004,7 @@ depends on the operations supported by the <tt class="literal"><span class="pre"
|
||||
core interface functions of <tt class="literal"><span class="pre">iterator_facade</span></tt> are redefined in the
|
||||
<tt class="literal"><span class="pre">Derived</span></tt> class.</p>
|
||||
<div class="section" id="class-template-iterator-adaptor">
|
||||
<h3><a class="toc-backref" href="#id32" name="class-template-iterator-adaptor">Class template <tt class="literal"><span class="pre">iterator_adaptor</span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id33" name="class-template-iterator-adaptor">Class template <tt class="literal"><span class="pre">iterator_adaptor</span></tt></a></h3>
|
||||
<!-- Version 1.4 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG for TR1. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -1053,13 +1053,13 @@ class iterator_adaptor
|
||||
</pre>
|
||||
<a class="target" id="requirements" name="requirements"></a></div>
|
||||
<div class="section" id="iterator-adaptor-requirements">
|
||||
<h3><a class="toc-backref" href="#id33" name="iterator-adaptor-requirements"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> requirements</a></h3>
|
||||
<h3><a class="toc-backref" href="#id34" name="iterator-adaptor-requirements"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> requirements</a></h3>
|
||||
<p>The <tt class="literal"><span class="pre">Derived</span></tt> template argument must be a publicly derived from
|
||||
<tt class="literal"><span class="pre">iterator_adaptor</span></tt>.</p>
|
||||
<p>The <tt class="literal"><span class="pre">Base</span></tt> argument shall be Assignable and Copy Constructible.</p>
|
||||
<a class="target" id="base-parameters" name="base-parameters"></a></div>
|
||||
<div class="section" id="iterator-adaptor-base-class-parameters">
|
||||
<h3><a class="toc-backref" href="#id34" name="iterator-adaptor-base-class-parameters"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> base class parameters</a></h3>
|
||||
<h3><a class="toc-backref" href="#id35" name="iterator-adaptor-base-class-parameters"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> base class parameters</a></h3>
|
||||
<p>The <em>V</em>, <em>C</em>, <em>R</em>, and <em>D</em> parameters of the <tt class="literal"><span class="pre">iterator_facade</span></tt>
|
||||
used as a base class in the summary of <tt class="literal"><span class="pre">iterator_adaptor</span></tt>
|
||||
above are defined as follows:</p>
|
||||
@@ -1089,7 +1089,7 @@ above are defined as follows:</p>
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="iterator-adaptor-models">
|
||||
<h3><a class="toc-backref" href="#id35" name="iterator-adaptor-models"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> models</a></h3>
|
||||
<h3><a class="toc-backref" href="#id36" name="iterator-adaptor-models"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> models</a></h3>
|
||||
<p>In order for <tt class="literal"><span class="pre">Derived</span></tt> to model the iterator concepts corresponding
|
||||
to <tt class="literal"><span class="pre">iterator_traits<Derived>::iterator_category</span></tt>, the expressions
|
||||
involving <tt class="literal"><span class="pre">m_iterator</span></tt> in the specifications of those private member
|
||||
@@ -1099,7 +1099,7 @@ expression involving <tt class="literal"><span class="pre">Derived</span></tt> i
|
||||
<!-- The above is confusing and needs a rewrite. -JGS -->
|
||||
</div>
|
||||
<div class="section" id="iterator-adaptor-public-operations">
|
||||
<h3><a class="toc-backref" href="#id36" name="iterator-adaptor-public-operations"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> public operations</a></h3>
|
||||
<h3><a class="toc-backref" href="#id37" name="iterator-adaptor-public-operations"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> public operations</a></h3>
|
||||
<p><tt class="literal"><span class="pre">iterator_adaptor();</span></tt></p>
|
||||
<table class="field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -1133,7 +1133,7 @@ expression involving <tt class="literal"><span class="pre">Derived</span></tt> i
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="iterator-adaptor-protected-member-functions">
|
||||
<h3><a class="toc-backref" href="#id37" name="iterator-adaptor-protected-member-functions"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> protected member functions</a></h3>
|
||||
<h3><a class="toc-backref" href="#id38" name="iterator-adaptor-protected-member-functions"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> protected member functions</a></h3>
|
||||
<p><tt class="literal"><span class="pre">Base</span> <span class="pre">const&</span> <span class="pre">base_reference()</span> <span class="pre">const;</span></tt></p>
|
||||
<table class="field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -1154,7 +1154,7 @@ expression involving <tt class="literal"><span class="pre">Derived</span></tt> i
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="iterator-adaptor-private-member-functions">
|
||||
<h3><a class="toc-backref" href="#id38" name="iterator-adaptor-private-member-functions"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> private member functions</a></h3>
|
||||
<h3><a class="toc-backref" href="#id39" name="iterator-adaptor-private-member-functions"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> private member functions</a></h3>
|
||||
<p><tt class="literal"><span class="pre">typename</span> <span class="pre">iterator_adaptor::reference</span> <span class="pre">dereference()</span> <span class="pre">const;</span></tt></p>
|
||||
<table class="field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
@@ -1223,7 +1223,7 @@ typename iterator_adaptor::difference_type distance_to(
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="specialized-adaptors-lib-iterator-special-adaptors">
|
||||
<h2><a class="toc-backref" href="#id39" name="specialized-adaptors-lib-iterator-special-adaptors">Specialized adaptors [lib.iterator.special.adaptors]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id40" name="specialized-adaptors-lib-iterator-special-adaptors">Specialized adaptors [lib.iterator.special.adaptors]</a></h2>
|
||||
<p>The <tt class="literal"><span class="pre">enable_if_convertible<X,Y>::type</span></tt> expression used in
|
||||
this section is for exposition purposes. The converting constructors
|
||||
for specialized adaptors should be only be in an overload set provided
|
||||
@@ -1252,7 +1252,7 @@ take the constructor out of the overload set when the types are not
|
||||
implicitly convertible.
|
||||
]</p>
|
||||
<div class="section" id="indirect-iterator">
|
||||
<h3><a class="toc-backref" href="#id40" name="indirect-iterator">Indirect iterator</a></h3>
|
||||
<h3><a class="toc-backref" href="#id41" name="indirect-iterator">Indirect iterator</a></h3>
|
||||
<p><tt class="literal"><span class="pre">indirect_iterator</span></tt> adapts an iterator by applying an
|
||||
<em>extra</em> dereference inside of <tt class="literal"><span class="pre">operator*()</span></tt>. For example, this
|
||||
iterator adaptor makes it possible to view a container of pointers
|
||||
@@ -1262,7 +1262,7 @@ auxiliary traits, <tt class="literal"><span class="pre">pointee</span></tt> and
|
||||
provide support for underlying iterators whose <tt class="literal"><span class="pre">value_type</span></tt> is
|
||||
not an iterator.</p>
|
||||
<div class="section" id="class-template-pointee">
|
||||
<h4><a class="toc-backref" href="#id41" name="class-template-pointee">Class template <tt class="literal"><span class="pre">pointee</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id42" name="class-template-pointee">Class template <tt class="literal"><span class="pre">pointee</span></tt></a></h4>
|
||||
<!-- Copyright David Abrahams 2004. Use, modification and distribution is -->
|
||||
<!-- subject to the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
@@ -1306,7 +1306,7 @@ else
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="class-template-indirect-reference">
|
||||
<h4><a class="toc-backref" href="#id42" name="class-template-indirect-reference">Class template <tt class="literal"><span class="pre">indirect_reference</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id43" name="class-template-indirect-reference">Class template <tt class="literal"><span class="pre">indirect_reference</span></tt></a></h4>
|
||||
<!-- Copyright David Abrahams 2004. Use, modification and distribution is -->
|
||||
<!-- subject to the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
@@ -1341,7 +1341,7 @@ else
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="class-template-indirect-iterator">
|
||||
<h4><a class="toc-backref" href="#id43" name="class-template-indirect-iterator">Class template <tt class="literal"><span class="pre">indirect_iterator</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id44" name="class-template-indirect-iterator">Class template <tt class="literal"><span class="pre">indirect_iterator</span></tt></a></h4>
|
||||
<pre class="literal-block">
|
||||
template <
|
||||
class Iterator
|
||||
@@ -1381,9 +1381,9 @@ private:
|
||||
Iterator m_iterator; // exposition
|
||||
};
|
||||
</pre>
|
||||
<p>The member types of <tt class="literal"><span class="pre">indirect_iterator</span></tt> are defined according to the
|
||||
following pseudo-code. We use the abbreviation
|
||||
<tt class="literal"><span class="pre">V=iterator_traits<Iterator>::value_type</span></tt>.:</p>
|
||||
<p>The member types of <tt class="literal"><span class="pre">indirect_iterator</span></tt> are defined according to
|
||||
the following pseudo-code, where <tt class="literal"><span class="pre">V</span></tt> is
|
||||
<tt class="literal"><span class="pre">iterator_traits<Iterator>::value_type</span></tt></p>
|
||||
<pre class="literal-block">
|
||||
if (Value is use_default) then
|
||||
typedef remove_const<pointee<V>::type>::type value_type;
|
||||
@@ -1407,14 +1407,19 @@ if (Difference is use_default)
|
||||
typedef iterator_traits<Iterator>::difference_type difference_type;
|
||||
else
|
||||
typedef Difference difference_type;
|
||||
|
||||
if (CategoryOrTraversal is use_default)
|
||||
typedef <a class="reference" href="#id11"><em>iterator-category</em></a>(
|
||||
iterator_traversal<Iterator>::type,``reference``,``value_type``
|
||||
) iterator_category;
|
||||
else
|
||||
typedef <a class="reference" href="#id11"><em>iterator-category</em></a>(
|
||||
CategoryOrTraversal,``reference``,``value_type``
|
||||
) iterator_category;
|
||||
</pre>
|
||||
<p>The <tt class="literal"><span class="pre">iterator_category</span></tt> member is <tt class="literal"><span class="pre">facade_iterator_category(C,</span>
|
||||
<span class="pre">value_type,</span> <span class="pre">reference)</span></tt> where if <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is
|
||||
<tt class="literal"><span class="pre">use_default</span></tt>, <tt class="literal"><span class="pre">C</span></tt> is <tt class="literal"><span class="pre">iterator_traversal<Iterator>::type</span></tt> and
|
||||
otherwise <tt class="literal"><span class="pre">C</span></tt> is <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="indirect-iterator-requirements">
|
||||
<h4><a class="toc-backref" href="#id44" name="indirect-iterator-requirements"><tt class="literal"><span class="pre">indirect_iterator</span></tt> requirements</a></h4>
|
||||
<h4><a class="toc-backref" href="#id45" name="indirect-iterator-requirements"><tt class="literal"><span class="pre">indirect_iterator</span></tt> requirements</a></h4>
|
||||
<p>The expression <tt class="literal"><span class="pre">*v</span></tt>, where <tt class="literal"><span class="pre">v</span></tt> is an object of
|
||||
<tt class="literal"><span class="pre">iterator_traits<Iterator>::value_type</span></tt>, shall be valid
|
||||
expression and convertible to <tt class="literal"><span class="pre">reference</span></tt>. <tt class="literal"><span class="pre">Iterator</span></tt> shall
|
||||
@@ -1428,7 +1433,7 @@ parameter is not <tt class="literal"><span class="pre">use_default</span></tt>,
|
||||
deducing the default for the <tt class="literal"><span class="pre">value_type</span></tt> member.]</p>
|
||||
</div>
|
||||
<div class="section" id="indirect-iterator-models">
|
||||
<h4><a class="toc-backref" href="#id45" name="indirect-iterator-models"><tt class="literal"><span class="pre">indirect_iterator</span></tt> models</a></h4>
|
||||
<h4><a class="toc-backref" href="#id46" name="indirect-iterator-models"><tt class="literal"><span class="pre">indirect_iterator</span></tt> models</a></h4>
|
||||
<p>In addition to the concepts indicated by <tt class="literal"><span class="pre">iterator_category</span></tt>
|
||||
and by <tt class="literal"><span class="pre">iterator_traversal<indirect_iterator>::type</span></tt>, a
|
||||
specialization of <tt class="literal"><span class="pre">indirect_iterator</span></tt> models the following
|
||||
@@ -1445,11 +1450,11 @@ expression (where <tt class="literal"><span class="pre">t</span></tt> is an obje
|
||||
</ul>
|
||||
</blockquote>
|
||||
<p><tt class="literal"><span class="pre">indirect_iterator<X,V1,C1,R1,D1></span></tt> is interoperable with
|
||||
<tt class="literal"><span class="pre">indirect_iterator<Y,V2,C2,R2,D2></span></tt> if and only if iterator <tt class="literal"><span class="pre">X</span></tt> is
|
||||
interoperable with iterator <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
<tt class="literal"><span class="pre">indirect_iterator<Y,V2,C2,R2,D2></span></tt> if and only if <tt class="literal"><span class="pre">X</span></tt> is
|
||||
interoperable with <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="indirect-iterator-operations">
|
||||
<h4><a class="toc-backref" href="#id46" name="indirect-iterator-operations"><tt class="literal"><span class="pre">indirect_iterator</span></tt> operations</a></h4>
|
||||
<h4><a class="toc-backref" href="#id47" name="indirect-iterator-operations"><tt class="literal"><span class="pre">indirect_iterator</span></tt> operations</a></h4>
|
||||
<p>In addition to the operations required by the concepts described
|
||||
above, specializations of <tt class="literal"><span class="pre">indirect_iterator</span></tt> provide the
|
||||
following operations.</p>
|
||||
@@ -1541,11 +1546,11 @@ indirect_iterator(
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="reverse-iterator">
|
||||
<h3><a class="toc-backref" href="#id47" name="reverse-iterator">Reverse iterator</a></h3>
|
||||
<h3><a class="toc-backref" href="#id48" name="reverse-iterator">Reverse iterator</a></h3>
|
||||
<p>The reverse iterator adaptor iterates through the adapted iterator
|
||||
range in the opposite direction.</p>
|
||||
<div class="section" id="class-template-reverse-iterator">
|
||||
<h4><a class="toc-backref" href="#id48" name="class-template-reverse-iterator">Class template <tt class="literal"><span class="pre">reverse_iterator</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id49" name="class-template-reverse-iterator">Class template <tt class="literal"><span class="pre">reverse_iterator</span></tt></a></h4>
|
||||
<pre class="literal-block">
|
||||
template <class Iterator>
|
||||
class reverse_iterator
|
||||
@@ -1582,11 +1587,11 @@ Lvalue Iterator, then <tt class="literal"><span class="pre">iterator_category</s
|
||||
convertible to <tt class="literal"><span class="pre">input_iterator_tag</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="reverse-iterator-requirements">
|
||||
<h4><a class="toc-backref" href="#id49" name="reverse-iterator-requirements"><tt class="literal"><span class="pre">reverse_iterator</span></tt> requirements</a></h4>
|
||||
<h4><a class="toc-backref" href="#id50" name="reverse-iterator-requirements"><tt class="literal"><span class="pre">reverse_iterator</span></tt> requirements</a></h4>
|
||||
<p><tt class="literal"><span class="pre">Iterator</span></tt> must be a model of Bidirectional Traversal Iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="reverse-iterator-models">
|
||||
<h4><a class="toc-backref" href="#id50" name="reverse-iterator-models"><tt class="literal"><span class="pre">reverse_iterator</span></tt> models</a></h4>
|
||||
<h4><a class="toc-backref" href="#id51" name="reverse-iterator-models"><tt class="literal"><span class="pre">reverse_iterator</span></tt> models</a></h4>
|
||||
<p>A specialization of <tt class="literal"><span class="pre">reverse_iterator</span></tt> models the same standard
|
||||
traversal and access iterator concepts modeled by its <tt class="literal"><span class="pre">Iterator</span></tt>
|
||||
argument. In addition, it models the old iterator concepts
|
||||
@@ -1624,7 +1629,7 @@ Random Access Traversal Iterator</td>
|
||||
if and only if iterator <tt class="literal"><span class="pre">X</span></tt> is interoperable with iterator <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="reverse-iterator-operations">
|
||||
<h4><a class="toc-backref" href="#id51" name="reverse-iterator-operations"><tt class="literal"><span class="pre">reverse_iterator</span></tt> operations</a></h4>
|
||||
<h4><a class="toc-backref" href="#id52" name="reverse-iterator-operations"><tt class="literal"><span class="pre">reverse_iterator</span></tt> operations</a></h4>
|
||||
<p>In addition to the operations required by the concepts modeled by
|
||||
<tt class="literal"><span class="pre">reverse_iterator</span></tt>, <tt class="literal"><span class="pre">reverse_iterator</span></tt> provides the following
|
||||
operations.</p>
|
||||
@@ -1714,12 +1719,12 @@ return *--tmp;
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="transform-iterator">
|
||||
<h3><a class="toc-backref" href="#id52" name="transform-iterator">Transform iterator</a></h3>
|
||||
<h3><a class="toc-backref" href="#id53" name="transform-iterator">Transform iterator</a></h3>
|
||||
<p>The transform iterator adapts an iterator by modifying the
|
||||
<tt class="literal"><span class="pre">operator*</span></tt> to apply a function object to the result of
|
||||
dereferencing the iterator and returning the result.</p>
|
||||
<div class="section" id="class-template-transform-iterator">
|
||||
<h4><a class="toc-backref" href="#id53" name="class-template-transform-iterator">Class template <tt class="literal"><span class="pre">transform_iterator</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id54" name="class-template-transform-iterator">Class template <tt class="literal"><span class="pre">transform_iterator</span></tt></a></h4>
|
||||
<!-- Version 1.3 of this document was accepted for TR1 -->
|
||||
<pre class="literal-block">
|
||||
template <class UnaryFunction,
|
||||
@@ -1772,7 +1777,7 @@ model Readable Lvalue Iterator then <tt class="literal"><span class="pre">iterat
|
||||
convertible to <tt class="literal"><span class="pre">input_iterator_tag</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="transform-iterator-requirements">
|
||||
<h4><a class="toc-backref" href="#id54" name="transform-iterator-requirements"><tt class="literal"><span class="pre">transform_iterator</span></tt> requirements</a></h4>
|
||||
<h4><a class="toc-backref" href="#id55" name="transform-iterator-requirements"><tt class="literal"><span class="pre">transform_iterator</span></tt> requirements</a></h4>
|
||||
<p>The type <tt class="literal"><span class="pre">UnaryFunction</span></tt> must be Assignable, Copy Constructible, and
|
||||
the expression <tt class="literal"><span class="pre">f(*i)</span></tt> must be valid where <tt class="literal"><span class="pre">f</span></tt> is an object of
|
||||
type <tt class="literal"><span class="pre">UnaryFunction</span></tt>, <tt class="literal"><span class="pre">i</span></tt> is an object of type <tt class="literal"><span class="pre">Iterator</span></tt>, and
|
||||
@@ -1781,7 +1786,7 @@ where the type of <tt class="literal"><span class="pre">f(*i)</span></tt> must b
|
||||
<p>The argument <tt class="literal"><span class="pre">Iterator</span></tt> shall model Readable Iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="transform-iterator-models">
|
||||
<h4><a class="toc-backref" href="#id55" name="transform-iterator-models"><tt class="literal"><span class="pre">transform_iterator</span></tt> models</a></h4>
|
||||
<h4><a class="toc-backref" href="#id56" name="transform-iterator-models"><tt class="literal"><span class="pre">transform_iterator</span></tt> models</a></h4>
|
||||
<p>The resulting <tt class="literal"><span class="pre">transform_iterator</span></tt> models the most refined of the
|
||||
following options that is also modeled by <tt class="literal"><span class="pre">Iterator</span></tt>.</p>
|
||||
<blockquote>
|
||||
@@ -1828,7 +1833,7 @@ mutable iterator (as defined in the old iterator requirements).</p>
|
||||
interoperable with iterator <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="transform-iterator-operations">
|
||||
<h4><a class="toc-backref" href="#id56" name="transform-iterator-operations"><tt class="literal"><span class="pre">transform_iterator</span></tt> operations</a></h4>
|
||||
<h4><a class="toc-backref" href="#id57" name="transform-iterator-operations"><tt class="literal"><span class="pre">transform_iterator</span></tt> operations</a></h4>
|
||||
<p>In addition to the operations required by the concepts modeled by
|
||||
<tt class="literal"><span class="pre">transform_iterator</span></tt>, <tt class="literal"><span class="pre">transform_iterator</span></tt> provides the following
|
||||
operations.</p>
|
||||
@@ -1921,7 +1926,7 @@ transform_iterator(
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator">
|
||||
<h3><a class="toc-backref" href="#id57" name="filter-iterator">Filter iterator</a></h3>
|
||||
<h3><a class="toc-backref" href="#id58" name="filter-iterator">Filter iterator</a></h3>
|
||||
<p>The filter iterator adaptor creates a view of an iterator range in
|
||||
which some elements of the range are skipped. A predicate function
|
||||
object controls which elements are skipped. When the predicate is
|
||||
@@ -1933,7 +1938,7 @@ underlying range. A filter iterator is therefore constructed with pair
|
||||
of iterators indicating the range of elements in the unfiltered
|
||||
sequence to be traversed.</p>
|
||||
<div class="section" id="class-template-filter-iterator">
|
||||
<h4><a class="toc-backref" href="#id58" name="class-template-filter-iterator">Class template <tt class="literal"><span class="pre">filter_iterator</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id59" name="class-template-filter-iterator">Class template <tt class="literal"><span class="pre">filter_iterator</span></tt></a></h4>
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt -->
|
||||
<!-- 2004. Use, modification and distribution is subject to the Boost -->
|
||||
<!-- Software License, Version 1.0. (See accompanying file -->
|
||||
@@ -1974,7 +1979,7 @@ Iterator then <tt class="literal"><span class="pre">iterator_category</span></tt
|
||||
convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-requirements">
|
||||
<h4><a class="toc-backref" href="#id59" name="filter-iterator-requirements"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h4>
|
||||
<h4><a class="toc-backref" href="#id60" name="filter-iterator-requirements"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h4>
|
||||
<p>The <tt class="literal"><span class="pre">Predicate</span></tt> argument must be Assignable, Copy Constructible, and
|
||||
the expression <tt class="literal"><span class="pre">p(x)</span></tt> must be valid where <tt class="literal"><span class="pre">p</span></tt> is an object of type
|
||||
<tt class="literal"><span class="pre">Predicate</span></tt>, <tt class="literal"><span class="pre">x</span></tt> is an object of type
|
||||
@@ -1985,7 +1990,7 @@ Iterator and Single Pass Iterator or it shall meet the requirements of
|
||||
Input Iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-models">
|
||||
<h4><a class="toc-backref" href="#id60" name="filter-iterator-models"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></h4>
|
||||
<h4><a class="toc-backref" href="#id61" name="filter-iterator-models"><tt class="literal"><span class="pre">filter_iterator</span></tt> models</a></h4>
|
||||
<p>The concepts that <tt class="literal"><span class="pre">filter_iterator</span></tt> models are dependent on which
|
||||
concepts the <tt class="literal"><span class="pre">Iterator</span></tt> argument models, as specified in the
|
||||
following tables.</p>
|
||||
@@ -2056,7 +2061,7 @@ following tables.</p>
|
||||
if and only if iterator <tt class="literal"><span class="pre">X</span></tt> is interoperable with iterator <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="filter-iterator-operations">
|
||||
<h4><a class="toc-backref" href="#id61" name="filter-iterator-operations"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></h4>
|
||||
<h4><a class="toc-backref" href="#id62" name="filter-iterator-operations"><tt class="literal"><span class="pre">filter_iterator</span></tt> operations</a></h4>
|
||||
<p>In addition to those operations required by the concepts that
|
||||
<tt class="literal"><span class="pre">filter_iterator</span></tt> models, <tt class="literal"><span class="pre">filter_iterator</span></tt> provides the following
|
||||
operations.</p>
|
||||
@@ -2167,12 +2172,12 @@ or <tt class="literal"><span class="pre">m_pred(*m_iter)</span> <span class="pre
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator">
|
||||
<h3><a class="toc-backref" href="#id62" name="counting-iterator">Counting iterator</a></h3>
|
||||
<h3><a class="toc-backref" href="#id63" name="counting-iterator">Counting iterator</a></h3>
|
||||
<p><tt class="literal"><span class="pre">counting_iterator</span></tt> adapts an object by adding an <tt class="literal"><span class="pre">operator*</span></tt> that
|
||||
returns the current value of the object. All other iterator operations
|
||||
are forwarded to the adapted object.</p>
|
||||
<div class="section" id="class-template-counting-iterator">
|
||||
<h4><a class="toc-backref" href="#id63" name="class-template-counting-iterator">Class template <tt class="literal"><span class="pre">counting_iterator</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id64" name="class-template-counting-iterator">Class template <tt class="literal"><span class="pre">counting_iterator</span></tt></a></h4>
|
||||
<pre class="literal-block">
|
||||
template <
|
||||
class Incrementable
|
||||
@@ -2199,24 +2204,28 @@ class counting_iterator
|
||||
Incrementable m_inc; // exposition
|
||||
};
|
||||
</pre>
|
||||
<p>If the <tt class="literal"><span class="pre">Difference</span></tt> argument is <tt class="literal"><span class="pre">use_default</span></tt> then the
|
||||
<tt class="literal"><span class="pre">difference_type</span></tt> member is an unspecified signed integral
|
||||
<p>If the <tt class="literal"><span class="pre">Difference</span></tt> argument is <tt class="literal"><span class="pre">use_default</span></tt> then
|
||||
<tt class="literal"><span class="pre">difference_type</span></tt> is an unspecified signed integral
|
||||
type. Otherwise <tt class="literal"><span class="pre">difference_type</span></tt> is <tt class="literal"><span class="pre">Difference</span></tt>.</p>
|
||||
<p>If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is not <tt class="literal"><span class="pre">use_default</span></tt> then the member
|
||||
<tt class="literal"><span class="pre">iterator_category</span></tt> is <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>. Otherwise, if
|
||||
<tt class="literal"><span class="pre">numeric_limits<Incrementable>::is_specialized</span></tt>, then
|
||||
<tt class="literal"><span class="pre">iterator_category</span></tt> is a
|
||||
<tt class="literal"><span class="pre">facade_iterator_category(random_access_traversal_tag,</span> <span class="pre">Incrementable,</span> <span class="pre">const</span> <span class="pre">Incrementable&)</span></tt>.
|
||||
Otherwise, <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
<tt class="literal"><span class="pre">facade_iterator_category(iterator_traversal<Incrementable>::type,</span> <span class="pre">Incrementable,</span> <span class="pre">const</span> <span class="pre">Incrementable&)</span></tt>.</p>
|
||||
<dl>
|
||||
<dt>[<em>Note:</em> implementers are encouraged to provide an implementation of</dt>
|
||||
<dd><tt class="literal"><span class="pre">operator-</span></tt> and the default <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>
|
||||
<p><tt class="literal"><span class="pre">iterator_category</span></tt> is determined according to the following
|
||||
algorithm:</p>
|
||||
<pre class="literal-block">
|
||||
if (CategoryOrTraversal is not use_default)
|
||||
return CategoryOrTraversal
|
||||
else if (numeric_limits<Incrementable>::is_specialized)
|
||||
return <a class="reference" href="#id11"><em>iterator-category</em></a>(
|
||||
random_access_traversal_tag, Incrementable, const Incrementable&)
|
||||
else
|
||||
return <a class="reference" href="#id11"><em>iterator-category</em></a>(
|
||||
iterator_traversal<Incrementable>::type,
|
||||
Incrementable, const Incrementable&)
|
||||
</pre>
|
||||
<p>[<em>Note:</em> implementers are encouraged to provide an implementation
|
||||
of <tt class="literal"><span class="pre">operator-</span></tt> and a default <tt class="literal"><span class="pre">difference_type</span></tt> that avoid
|
||||
overflows when <tt class="literal"><span class="pre">Incrementable</span></tt> is a numeric type.]</p>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-requirements">
|
||||
<h4><a class="toc-backref" href="#id64" name="counting-iterator-requirements"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></h4>
|
||||
<h4><a class="toc-backref" href="#id65" name="counting-iterator-requirements"><tt class="literal"><span class="pre">counting_iterator</span></tt> requirements</a></h4>
|
||||
<p>The <tt class="literal"><span class="pre">Incrementable</span></tt> argument shall be Copy Constructible and Assignable.</p>
|
||||
<p>If <tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to <tt class="literal"><span class="pre">forward_iterator_tag</span></tt>
|
||||
or <tt class="literal"><span class="pre">forward_traversal_tag</span></tt>, the following must be well-formed:</p>
|
||||
@@ -2242,7 +2251,7 @@ i < j;
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-models">
|
||||
<h4><a class="toc-backref" href="#id65" name="counting-iterator-models"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></h4>
|
||||
<h4><a class="toc-backref" href="#id66" name="counting-iterator-models"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></h4>
|
||||
<p>Specializations of <tt class="literal"><span class="pre">counting_iterator</span></tt> model Readable Lvalue
|
||||
Iterator. In addition, they model the concepts corresponding to the
|
||||
iterator tags to which their <tt class="literal"><span class="pre">iterator_category</span></tt> is convertible.
|
||||
@@ -2258,7 +2267,7 @@ concepts modeled by <tt class="literal"><span class="pre">Incrementable</span></
|
||||
interoperable with iterator <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="counting-iterator-operations">
|
||||
<h4><a class="toc-backref" href="#id66" name="counting-iterator-operations"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></h4>
|
||||
<h4><a class="toc-backref" href="#id67" name="counting-iterator-operations"><tt class="literal"><span class="pre">counting_iterator</span></tt> operations</a></h4>
|
||||
<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>
|
||||
@@ -2334,7 +2343,7 @@ operations.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="function-output-iterator">
|
||||
<h3><a class="toc-backref" href="#id67" name="function-output-iterator">Function output iterator</a></h3>
|
||||
<h3><a class="toc-backref" href="#id68" name="function-output-iterator">Function output iterator</a></h3>
|
||||
<p>The function output iterator adaptor makes it easier to create custom
|
||||
output iterators. The adaptor takes a unary function and creates a
|
||||
model of Output Iterator. Each item assigned to the output iterator is
|
||||
@@ -2343,7 +2352,7 @@ iterator is that creating a conforming output iterator is non-trivial,
|
||||
particularly because the proper implementation usually requires a
|
||||
proxy object.</p>
|
||||
<div class="section" id="class-template-function-output-iterator">
|
||||
<h4><a class="toc-backref" href="#id68" name="class-template-function-output-iterator">Class template <tt class="literal"><span class="pre">function_output_iterator</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id69" name="class-template-function-output-iterator">Class template <tt class="literal"><span class="pre">function_output_iterator</span></tt></a></h4>
|
||||
<pre class="literal-block">
|
||||
template <class UnaryFunction>
|
||||
class function_output_iterator {
|
||||
@@ -2365,16 +2374,16 @@ private:
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="function-output-iterator-requirements">
|
||||
<h4><a class="toc-backref" href="#id69" name="function-output-iterator-requirements"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></h4>
|
||||
<h4><a class="toc-backref" href="#id70" name="function-output-iterator-requirements"><tt class="literal"><span class="pre">function_output_iterator</span></tt> requirements</a></h4>
|
||||
<p><tt class="literal"><span class="pre">UnaryFunction</span></tt> must be Assignable and Copy Constructible.</p>
|
||||
</div>
|
||||
<div class="section" id="function-output-iterator-models">
|
||||
<h4><a class="toc-backref" href="#id70" name="function-output-iterator-models"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></h4>
|
||||
<h4><a class="toc-backref" href="#id71" name="function-output-iterator-models"><tt class="literal"><span class="pre">function_output_iterator</span></tt> models</a></h4>
|
||||
<p><tt class="literal"><span class="pre">function_output_iterator</span></tt> is a model of the Writable and
|
||||
Incrementable Iterator concepts.</p>
|
||||
</div>
|
||||
<div class="section" id="function-output-iterator-operations">
|
||||
<h4><a class="toc-backref" href="#id71" name="function-output-iterator-operations"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></h4>
|
||||
<h4><a class="toc-backref" href="#id72" name="function-output-iterator-operations"><tt class="literal"><span class="pre">function_output_iterator</span></tt> operations</a></h4>
|
||||
<p><tt class="literal"><span class="pre">explicit</span> <span class="pre">function_output_iterator(const</span> <span class="pre">UnaryFunction&</span> <span class="pre">f</span> <span class="pre">=</span> <span class="pre">UnaryFunction());</span></tt></p>
|
||||
<table class="field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
.. |iterator-category| replace:: *iterator-category*
|
||||
.. _iterator-category:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
*iterator-category*\ (C,R,V) :=
|
||||
|
||||
@@ -98,9 +98,9 @@ private:
|
||||
Iterator m_iterator; // exposition
|
||||
};
|
||||
</pre>
|
||||
<p>The member types of <tt class="literal"><span class="pre">indirect_iterator</span></tt> are defined according to the
|
||||
following pseudo-code. We use the abbreviation
|
||||
<tt class="literal"><span class="pre">V=iterator_traits<Iterator>::value_type</span></tt>.:</p>
|
||||
<p>The member types of <tt class="literal"><span class="pre">indirect_iterator</span></tt> are defined according to
|
||||
the following pseudo-code, where <tt class="literal"><span class="pre">V</span></tt> is
|
||||
<tt class="literal"><span class="pre">iterator_traits<Iterator>::value_type</span></tt></p>
|
||||
<pre class="literal-block">
|
||||
if (Value is use_default) then
|
||||
typedef remove_const<pointee<V>::type>::type value_type;
|
||||
@@ -124,11 +124,16 @@ if (Difference is use_default)
|
||||
typedef iterator_traits<Iterator>::difference_type difference_type;
|
||||
else
|
||||
typedef Difference difference_type;
|
||||
|
||||
if (CategoryOrTraversal is use_default)
|
||||
typedef <a class="reference" href="iterator_facade.html#iterator-category"><em>iterator-category</em></a>(
|
||||
iterator_traversal<Iterator>::type,``reference``,``value_type``
|
||||
) iterator_category;
|
||||
else
|
||||
typedef <a class="reference" href="iterator_facade.html#iterator-category"><em>iterator-category</em></a>(
|
||||
CategoryOrTraversal,``reference``,``value_type``
|
||||
) iterator_category;
|
||||
</pre>
|
||||
<p>The <tt class="literal"><span class="pre">iterator_category</span></tt> member is <tt class="literal"><span class="pre">facade_iterator_category(C,</span>
|
||||
<span class="pre">value_type,</span> <span class="pre">reference)</span></tt> where if <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is
|
||||
<tt class="literal"><span class="pre">use_default</span></tt>, <tt class="literal"><span class="pre">C</span></tt> is <tt class="literal"><span class="pre">iterator_traversal<Iterator>::type</span></tt> and
|
||||
otherwise <tt class="literal"><span class="pre">C</span></tt> is <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="indirect-iterator-requirements">
|
||||
<h1><a class="toc-backref" href="#id3" name="indirect-iterator-requirements"><tt class="literal"><span class="pre">indirect_iterator</span></tt> requirements</a></h1>
|
||||
@@ -162,8 +167,8 @@ expression (where <tt class="literal"><span class="pre">t</span></tt> is an obje
|
||||
</ul>
|
||||
</blockquote>
|
||||
<p><tt class="literal"><span class="pre">indirect_iterator<X,V1,C1,R1,D1></span></tt> is interoperable with
|
||||
<tt class="literal"><span class="pre">indirect_iterator<Y,V2,C2,R2,D2></span></tt> if and only if iterator <tt class="literal"><span class="pre">X</span></tt> is
|
||||
interoperable with iterator <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
<tt class="literal"><span class="pre">indirect_iterator<Y,V2,C2,R2,D2></span></tt> if and only if <tt class="literal"><span class="pre">X</span></tt> is
|
||||
interoperable with <tt class="literal"><span class="pre">Y</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="indirect-iterator-operations">
|
||||
<h1><a class="toc-backref" href="#id5" name="indirect-iterator-operations"><tt class="literal"><span class="pre">indirect_iterator</span></tt> operations</a></h1>
|
||||
|
||||
@@ -25,3 +25,6 @@
|
||||
|
||||
.. include:: indirect_iterator_ref.rst
|
||||
.. include:: indirect_iterator_eg.rst
|
||||
|
||||
.. _iterator-category: iterator_facade.html#iterator-category
|
||||
.. |iterator-category| replace:: *iterator-category*
|
||||
@@ -39,9 +39,11 @@
|
||||
};
|
||||
|
||||
|
||||
The member types of ``indirect_iterator`` are defined according to the
|
||||
following pseudo-code. We use the abbreviation
|
||||
``V=iterator_traits<Iterator>::value_type``.::
|
||||
The member types of ``indirect_iterator`` are defined according to
|
||||
the following pseudo-code, where ``V`` is
|
||||
``iterator_traits<Iterator>::value_type``
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
if (Value is use_default) then
|
||||
typedef remove_const<pointee<V>::type>::type value_type;
|
||||
@@ -57,21 +59,23 @@ following pseudo-code. We use the abbreviation
|
||||
typedef Reference reference;
|
||||
|
||||
if (Value is use_default) then
|
||||
typedef pointee<V>::type* pointer;
|
||||
typedef pointee<V>::type\* pointer;
|
||||
else
|
||||
typedef Value* pointer;
|
||||
typedef Value\* pointer;
|
||||
|
||||
if (Difference is use_default)
|
||||
typedef iterator_traits<Iterator>::difference_type difference_type;
|
||||
else
|
||||
typedef Difference difference_type;
|
||||
|
||||
|
||||
|
||||
The ``iterator_category`` member is ``facade_iterator_category(C,
|
||||
value_type, reference)`` where if ``CategoryOrTraversal`` is
|
||||
``use_default``, ``C`` is ``iterator_traversal<Iterator>::type`` and
|
||||
otherwise ``C`` is ``CategoryOrTraversal``.
|
||||
if (CategoryOrTraversal is use_default)
|
||||
typedef |iterator-category|_\ (
|
||||
iterator_traversal<Iterator>::type,``reference``,``value_type``
|
||||
) iterator_category;
|
||||
else
|
||||
typedef |iterator-category|_\ (
|
||||
CategoryOrTraversal,``reference``,``value_type``
|
||||
) iterator_category;
|
||||
|
||||
|
||||
``indirect_iterator`` requirements
|
||||
@@ -109,8 +113,8 @@ concepts, Where ``v`` is an object of
|
||||
* Lvalue Iterator if ``reference`` is a reference type.
|
||||
|
||||
``indirect_iterator<X,V1,C1,R1,D1>`` is interoperable with
|
||||
``indirect_iterator<Y,V2,C2,R2,D2>`` if and only if iterator ``X`` is
|
||||
interoperable with iterator ``Y``.
|
||||
``indirect_iterator<Y,V2,C2,R2,D2>`` if and only if ``X`` is
|
||||
interoperable with ``Y``.
|
||||
|
||||
|
||||
``indirect_iterator`` operations
|
||||
|
||||
+57
-57
@@ -45,43 +45,43 @@ and associated types, to be supplied by a derived iterator class.</td>
|
||||
<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="#overview" id="id21" name="id21">Overview</a><ul>
|
||||
<li><a class="reference" href="#usage" id="id22" name="id22">Usage</a></li>
|
||||
<li><a class="reference" href="#iterator-core-access" id="id23" name="id23">Iterator Core Access</a></li>
|
||||
<li><a class="reference" href="#operator" id="id24" name="id24"><tt class="literal"><span class="pre">operator[]</span></tt></a></li>
|
||||
<li><a class="reference" href="#id2" id="id25" name="id25"><tt class="literal"><span class="pre">operator-></span></tt></a></li>
|
||||
<li><a class="reference" href="#overview" id="id22" name="id22">Overview</a><ul>
|
||||
<li><a class="reference" href="#usage" id="id23" name="id23">Usage</a></li>
|
||||
<li><a class="reference" href="#iterator-core-access" id="id24" name="id24">Iterator Core Access</a></li>
|
||||
<li><a class="reference" href="#operator" id="id25" name="id25"><tt class="literal"><span class="pre">operator[]</span></tt></a></li>
|
||||
<li><a class="reference" href="#id2" id="id26" name="id26"><tt class="literal"><span class="pre">operator-></span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#reference" id="id26" name="id26">Reference</a><ul>
|
||||
<li><a class="reference" href="#iterator-facade-requirements" id="id27" name="id27"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></li>
|
||||
<li><a class="reference" href="#iterator-facade-operations" id="id28" name="id28"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></li>
|
||||
<li><a class="reference" href="#reference" id="id27" name="id27">Reference</a><ul>
|
||||
<li><a class="reference" href="#iterator-facade-requirements" id="id28" name="id28"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></li>
|
||||
<li><a class="reference" href="#iterator-facade-operations" id="id29" name="id29"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#tutorial-example" id="id29" name="id29">Tutorial Example</a><ul>
|
||||
<li><a class="reference" href="#the-problem" id="id30" name="id30">The Problem</a></li>
|
||||
<li><a class="reference" href="#a-basic-iterator-using-iterator-facade" id="id31" name="id31">A Basic Iterator Using <tt class="literal"><span class="pre">iterator_facade</span></tt></a><ul>
|
||||
<li><a class="reference" href="#template-arguments-for-iterator-facade" id="id32" name="id32">Template Arguments for <tt class="literal"><span class="pre">iterator_facade</span></tt></a><ul>
|
||||
<li><a class="reference" href="#derived" id="id33" name="id33"><tt class="literal"><span class="pre">Derived</span></tt></a></li>
|
||||
<li><a class="reference" href="#value" id="id34" name="id34"><tt class="literal"><span class="pre">Value</span></tt></a></li>
|
||||
<li><a class="reference" href="#categoryortraversal" id="id35" name="id35"><tt class="literal"><span class="pre">CategoryOrTraversal</span></tt></a></li>
|
||||
<li><a class="reference" href="#id10" id="id36" name="id36"><tt class="literal"><span class="pre">Reference</span></tt></a></li>
|
||||
<li><a class="reference" href="#difference" id="id37" name="id37"><tt class="literal"><span class="pre">Difference</span></tt></a></li>
|
||||
<li><a class="reference" href="#tutorial-example" id="id30" name="id30">Tutorial Example</a><ul>
|
||||
<li><a class="reference" href="#the-problem" id="id31" name="id31">The Problem</a></li>
|
||||
<li><a class="reference" href="#a-basic-iterator-using-iterator-facade" id="id32" name="id32">A Basic Iterator Using <tt class="literal"><span class="pre">iterator_facade</span></tt></a><ul>
|
||||
<li><a class="reference" href="#template-arguments-for-iterator-facade" id="id33" name="id33">Template Arguments for <tt class="literal"><span class="pre">iterator_facade</span></tt></a><ul>
|
||||
<li><a class="reference" href="#derived" id="id34" name="id34"><tt class="literal"><span class="pre">Derived</span></tt></a></li>
|
||||
<li><a class="reference" href="#value" id="id35" name="id35"><tt class="literal"><span class="pre">Value</span></tt></a></li>
|
||||
<li><a class="reference" href="#categoryortraversal" id="id36" name="id36"><tt class="literal"><span class="pre">CategoryOrTraversal</span></tt></a></li>
|
||||
<li><a class="reference" href="#id11" id="id37" name="id37"><tt class="literal"><span class="pre">Reference</span></tt></a></li>
|
||||
<li><a class="reference" href="#difference" id="id38" name="id38"><tt class="literal"><span class="pre">Difference</span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#constructors-and-data-members" id="id38" name="id38">Constructors and Data Members</a></li>
|
||||
<li><a class="reference" href="#implementing-the-core-operations" id="id39" name="id39">Implementing the Core Operations</a></li>
|
||||
<li><a class="reference" href="#constructors-and-data-members" id="id39" name="id39">Constructors and Data Members</a></li>
|
||||
<li><a class="reference" href="#implementing-the-core-operations" id="id40" name="id40">Implementing the Core Operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#a-constant-node-iterator" id="id40" name="id40">A constant <tt class="literal"><span class="pre">node_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#interoperability" id="id41" name="id41">Interoperability</a></li>
|
||||
<li><a class="reference" href="#telling-the-truth" id="id42" name="id42">Telling the Truth</a></li>
|
||||
<li><a class="reference" href="#wrap-up" id="id43" name="id43">Wrap Up</a></li>
|
||||
<li><a class="reference" href="#a-constant-node-iterator" id="id41" name="id41">A constant <tt class="literal"><span class="pre">node_iterator</span></tt></a></li>
|
||||
<li><a class="reference" href="#interoperability" id="id42" name="id42">Interoperability</a></li>
|
||||
<li><a class="reference" href="#telling-the-truth" id="id43" name="id43">Telling the Truth</a></li>
|
||||
<li><a class="reference" href="#wrap-up" id="id44" name="id44">Wrap Up</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="overview">
|
||||
<h1><a class="toc-backref" href="#id21" name="overview">Overview</a></h1>
|
||||
<h1><a class="toc-backref" href="#id22" name="overview">Overview</a></h1>
|
||||
<!-- Version 1.1 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG for TR1. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -126,7 +126,7 @@ impossible.</li>
|
||||
</ol>
|
||||
</blockquote>
|
||||
<div class="section" id="usage">
|
||||
<h2><a class="toc-backref" href="#id22" name="usage">Usage</a></h2>
|
||||
<h2><a class="toc-backref" href="#id23" name="usage">Usage</a></h2>
|
||||
<p>The user of <tt class="literal"><span class="pre">iterator_facade</span></tt> derives his iterator class from a
|
||||
specialization of <tt class="literal"><span class="pre">iterator_facade</span></tt> and passes the derived
|
||||
iterator class as <tt class="literal"><span class="pre">iterator_facade</span></tt>'s first template parameter.
|
||||
@@ -190,7 +190,7 @@ Iterator or a more-refined iterator concept, a default constructor is
|
||||
required.</p>
|
||||
</div>
|
||||
<div class="section" id="iterator-core-access">
|
||||
<h2><a class="toc-backref" href="#id23" name="iterator-core-access">Iterator Core Access</a></h2>
|
||||
<h2><a class="toc-backref" href="#id24" name="iterator-core-access">Iterator Core Access</a></h2>
|
||||
<p><tt class="literal"><span class="pre">iterator_facade</span></tt> and the operator implementations need to be able
|
||||
to access the core member functions in the derived class. Making the
|
||||
core member functions public would expose an implementation detail to
|
||||
@@ -224,7 +224,7 @@ open a safety loophole, as every core member function preserves the
|
||||
invariants of the iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="operator">
|
||||
<h2><a class="toc-backref" href="#id24" name="operator"><tt class="literal"><span class="pre">operator[]</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id25" name="operator"><tt class="literal"><span class="pre">operator[]</span></tt></a></h2>
|
||||
<p>The indexing operator for a generalized iterator presents special
|
||||
challenges. A random access iterator's <tt class="literal"><span class="pre">operator[]</span></tt> is only
|
||||
required to return something convertible to its <tt class="literal"><span class="pre">value_type</span></tt>.
|
||||
@@ -247,7 +247,7 @@ class; it will hide the one supplied by <tt class="literal"><span class="pre">it
|
||||
clients of her iterator.</p>
|
||||
<a class="target" id="operator-arrow" name="operator-arrow"></a></div>
|
||||
<div class="section" id="id2">
|
||||
<h2><a class="toc-backref" href="#id25" name="id2"><tt class="literal"><span class="pre">operator-></span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id26" name="id2"><tt class="literal"><span class="pre">operator-></span></tt></a></h2>
|
||||
<p>The <tt class="literal"><span class="pre">reference</span></tt> type of a readable iterator (and today's input
|
||||
iterator) need not in fact be a reference, so long as it is
|
||||
convertible to the iterator's <tt class="literal"><span class="pre">value_type</span></tt>. When the <tt class="literal"><span class="pre">value_type</span></tt>
|
||||
@@ -263,14 +263,14 @@ satisfied by the <tt class="literal"><span class="pre">iterator_facade</span></t
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<col />
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a name="cop95">[Cop95]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id8">2</a>)</em> [Coplien, 1995] Coplien, J., Curiously Recurring Template
|
||||
<tr><td class="label"><a name="cop95">[Cop95]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id9">2</a>)</em> [Coplien, 1995] Coplien, J., Curiously Recurring Template
|
||||
Patterns, C++ Report, February 1995, pp. 24-27.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="reference">
|
||||
<h1><a class="toc-backref" href="#id26" name="reference">Reference</a></h1>
|
||||
<h1><a class="toc-backref" href="#id27" name="reference">Reference</a></h1>
|
||||
<!-- Version 1.3 of this ReStructuredText document corresponds to
|
||||
n1530_, the paper accepted by the LWG for TR1. -->
|
||||
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All
|
||||
@@ -363,7 +363,7 @@ Derived operator+ (iterator_facade<Derived, V, TC, R, D> const&,
|
||||
<em>iterator-category</em>(CategoryOrTraversal, value_type, reference)
|
||||
</pre>
|
||||
<p>where <em>iterator-category</em> is defined as follows:</p>
|
||||
<pre class="literal-block">
|
||||
<a class="target" id="id6" name="id6"></a><pre class="literal-block">
|
||||
<em>iterator-category</em>(C,R,V) :=
|
||||
if (C is convertible to std::input_iterator_tag
|
||||
|| C is convertible to std::output_iterator_tag
|
||||
@@ -440,7 +440,7 @@ struct enable_if_interoperable
|
||||
{};
|
||||
</pre>
|
||||
<div class="section" id="iterator-facade-requirements">
|
||||
<h2><a class="toc-backref" href="#id27" name="iterator-facade-requirements"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></h2>
|
||||
<h2><a class="toc-backref" href="#id28" name="iterator-facade-requirements"><tt class="literal"><span class="pre">iterator_facade</span></tt> Requirements</a></h2>
|
||||
<p>The following table describes the typical valid expressions on
|
||||
<tt class="literal"><span class="pre">iterator_facade</span></tt>'s <tt class="literal"><span class="pre">Derived</span></tt> parameter, depending on the
|
||||
iterator concept(s) it will model. The operations in the first
|
||||
@@ -511,7 +511,7 @@ Iterator</td>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="iterator-facade-operations">
|
||||
<h2><a class="toc-backref" href="#id28" name="iterator-facade-operations"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></h2>
|
||||
<h2><a class="toc-backref" href="#id29" name="iterator-facade-operations"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></h2>
|
||||
<p>The operations in this section are described in terms of operations on
|
||||
the core interface of <tt class="literal"><span class="pre">Derived</span></tt> which may be inaccessible
|
||||
(i.e. private). The implementation should access these operations
|
||||
@@ -652,7 +652,7 @@ return tmp -= n;
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="tutorial-example">
|
||||
<h1><a class="toc-backref" href="#id29" name="tutorial-example">Tutorial Example</a></h1>
|
||||
<h1><a class="toc-backref" href="#id30" name="tutorial-example">Tutorial Example</a></h1>
|
||||
<!-- Copyright David Abrahams 2004. Use, modification and distribution is -->
|
||||
<!-- subject to the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
@@ -662,7 +662,7 @@ example of a linked list of polymorphic objects. This example was
|
||||
inspired by a <a class="reference" href="http://thread.gmane.org/gmane.comp.lib.boost.user/5100">posting</a> by Keith Macdonald on the <a class="reference" href="../../../more/mailing_lists.htm#users">Boost-Users</a>
|
||||
mailing list.</p>
|
||||
<div class="section" id="the-problem">
|
||||
<h2><a class="toc-backref" href="#id30" name="the-problem">The Problem</a></h2>
|
||||
<h2><a class="toc-backref" href="#id31" name="the-problem">The Problem</a></h2>
|
||||
<p>Say we've written a polymorphic linked list node base class:</p>
|
||||
<pre class="literal-block">
|
||||
# include <iostream>
|
||||
@@ -724,7 +724,7 @@ inline std::ostream& operator<<(std::ostream& s, node_base const&a
|
||||
lists.</p>
|
||||
</div>
|
||||
<div class="section" id="a-basic-iterator-using-iterator-facade">
|
||||
<h2><a class="toc-backref" href="#id31" name="a-basic-iterator-using-iterator-facade">A Basic Iterator Using <tt class="literal"><span class="pre">iterator_facade</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id32" name="a-basic-iterator-using-iterator-facade">A Basic Iterator Using <tt class="literal"><span class="pre">iterator_facade</span></tt></a></h2>
|
||||
<p>We will construct a <tt class="literal"><span class="pre">node_iterator</span></tt> class using inheritance from
|
||||
<tt class="literal"><span class="pre">iterator_facade</span></tt> to implement most of the iterator's operations.</p>
|
||||
<pre class="literal-block">
|
||||
@@ -738,24 +738,24 @@ class node_iterator
|
||||
};
|
||||
</pre>
|
||||
<div class="section" id="template-arguments-for-iterator-facade">
|
||||
<h3><a class="toc-backref" href="#id32" name="template-arguments-for-iterator-facade">Template Arguments for <tt class="literal"><span class="pre">iterator_facade</span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id33" name="template-arguments-for-iterator-facade">Template Arguments for <tt class="literal"><span class="pre">iterator_facade</span></tt></a></h3>
|
||||
<p><tt class="literal"><span class="pre">iterator_facade</span></tt> has several template parameters, so we must decide
|
||||
what types to use for the arguments. The parameters are <tt class="literal"><span class="pre">Derived</span></tt>,
|
||||
<tt class="literal"><span class="pre">Value</span></tt>, <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>, <tt class="literal"><span class="pre">Reference</span></tt>, and <tt class="literal"><span class="pre">Difference</span></tt>.</p>
|
||||
<div class="section" id="derived">
|
||||
<h4><a class="toc-backref" href="#id33" name="derived"><tt class="literal"><span class="pre">Derived</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id34" name="derived"><tt class="literal"><span class="pre">Derived</span></tt></a></h4>
|
||||
<p>Because <tt class="literal"><span class="pre">iterator_facade</span></tt> is meant to be used with the CRTP
|
||||
<a class="citation-reference" href="#cop95" id="id8" name="id8">[Cop95]</a> the first parameter is the iterator class name itself,
|
||||
<a class="citation-reference" href="#cop95" id="id9" name="id9">[Cop95]</a> the first parameter is the iterator class name itself,
|
||||
<tt class="literal"><span class="pre">node_iterator</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="value">
|
||||
<h4><a class="toc-backref" href="#id34" name="value"><tt class="literal"><span class="pre">Value</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id35" name="value"><tt class="literal"><span class="pre">Value</span></tt></a></h4>
|
||||
<p>The <tt class="literal"><span class="pre">Value</span></tt> parameter determines the <tt class="literal"><span class="pre">node_iterator</span></tt>'s
|
||||
<tt class="literal"><span class="pre">value_type</span></tt>. In this case, we are iterating over <tt class="literal"><span class="pre">node_base</span></tt>
|
||||
objects, so <tt class="literal"><span class="pre">Value</span></tt> will be <tt class="literal"><span class="pre">node_base</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="categoryortraversal">
|
||||
<h4><a class="toc-backref" href="#id35" name="categoryortraversal"><tt class="literal"><span class="pre">CategoryOrTraversal</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id36" name="categoryortraversal"><tt class="literal"><span class="pre">CategoryOrTraversal</span></tt></a></h4>
|
||||
<p>Now we have to determine which <a class="reference" href="new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal">iterator traversal concept</a> our
|
||||
<tt class="literal"><span class="pre">node_iterator</span></tt> is going to model. Singly-linked lists only have
|
||||
forward links, so our iterator can't can't be a <a class="reference" href="new-iter-concepts.html#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators">bidirectional
|
||||
@@ -763,19 +763,19 @@ traversal iterator</a>. Our iterator should be able to make multiple
|
||||
passes over the same linked list (unlike, say, an
|
||||
<tt class="literal"><span class="pre">istream_iterator</span></tt> which consumes the stream it traverses), so it
|
||||
must be a <a class="reference" href="new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">forward traversal iterator</a>. Therefore, we'll pass
|
||||
<tt class="literal"><span class="pre">boost::forward_traversal_tag</span></tt> in this position <a class="footnote-reference" href="#category" id="id9" name="id9"><sup>1</sup></a>.</p>
|
||||
<tt class="literal"><span class="pre">boost::forward_traversal_tag</span></tt> in this position <a class="footnote-reference" href="#category" id="id10" name="id10"><sup>1</sup></a>.</p>
|
||||
<table class="footnote" frame="void" id="category" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id9" name="category">[1]</a></td><td><tt class="literal"><span class="pre">iterator_facade</span></tt> also supports old-style category
|
||||
<tr><td class="label"><a class="fn-backref" href="#id10" name="category">[1]</a></td><td><tt class="literal"><span class="pre">iterator_facade</span></tt> also supports old-style category
|
||||
tags, so we could have passed <tt class="literal"><span class="pre">std::forward_iterator_tag</span></tt> here;
|
||||
either way, the resulting iterator's <tt class="literal"><span class="pre">iterator_category</span></tt> will
|
||||
end up being <tt class="literal"><span class="pre">std::forward_iterator_tag</span></tt>.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="id10">
|
||||
<h4><a class="toc-backref" href="#id36" name="id10"><tt class="literal"><span class="pre">Reference</span></tt></a></h4>
|
||||
<div class="section" id="id11">
|
||||
<h4><a class="toc-backref" href="#id37" name="id11"><tt class="literal"><span class="pre">Reference</span></tt></a></h4>
|
||||
<p>The <tt class="literal"><span class="pre">Reference</span></tt> argument becomes the type returned by
|
||||
<tt class="literal"><span class="pre">node_iterator</span></tt>'s dereference operation, and will also be the
|
||||
same as <tt class="literal"><span class="pre">std::iterator_traits<node_iterator>::reference</span></tt>. The
|
||||
@@ -784,7 +784,7 @@ library's default for this parameter is <tt class="literal"><span class="pre">Va
|
||||
type, we can omit this argument, or pass <tt class="literal"><span class="pre">use_default</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="difference">
|
||||
<h4><a class="toc-backref" href="#id37" name="difference"><tt class="literal"><span class="pre">Difference</span></tt></a></h4>
|
||||
<h4><a class="toc-backref" href="#id38" name="difference"><tt class="literal"><span class="pre">Difference</span></tt></a></h4>
|
||||
<p>The <tt class="literal"><span class="pre">Difference</span></tt> argument determines how the distance between
|
||||
two <tt class="literal"><span class="pre">node_iterator</span></tt>s will be measured and will also be the
|
||||
same as <tt class="literal"><span class="pre">std::iterator_traits<node_iterator>::difference_type</span></tt>.
|
||||
@@ -811,14 +811,14 @@ class node_iterator
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="constructors-and-data-members">
|
||||
<h3><a class="toc-backref" href="#id38" name="constructors-and-data-members">Constructors and Data Members</a></h3>
|
||||
<h3><a class="toc-backref" href="#id39" name="constructors-and-data-members">Constructors and Data Members</a></h3>
|
||||
<p>Next we need to decide how to represent the iterator's position.
|
||||
This representation will take the form of data members, so we'll
|
||||
also need to write constructors to initialize them. The
|
||||
<tt class="literal"><span class="pre">node_iterator</span></tt>'s position is quite naturally represented using
|
||||
a pointer to a <tt class="literal"><span class="pre">node_base</span></tt>. We'll need a constructor to build an
|
||||
iterator from a <tt class="literal"><span class="pre">node_base*</span></tt>, and a default constructor to
|
||||
satisfy the <a class="reference" href="new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">forward traversal iterator</a> requirements <a class="footnote-reference" href="#default" id="id11" name="id11"><sup>2</sup></a>.
|
||||
satisfy the <a class="reference" href="new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">forward traversal iterator</a> requirements <a class="footnote-reference" href="#default" id="id12" name="id12"><sup>2</sup></a>.
|
||||
Our <tt class="literal"><span class="pre">node_iterator</span></tt> then becomes:</p>
|
||||
<pre class="literal-block">
|
||||
# include "node.hpp"
|
||||
@@ -848,7 +848,7 @@ class node_iterator
|
||||
<table class="footnote" frame="void" id="default" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id11" name="default">[2]</a></td><td>Technically, the C++ standard places almost no
|
||||
<tr><td class="label"><a class="fn-backref" href="#id12" name="default">[2]</a></td><td>Technically, the C++ standard places almost no
|
||||
requirements on a default-constructed iterator, so if we were
|
||||
really concerned with efficiency, we could've written the
|
||||
default constructor to leave <tt class="literal"><span class="pre">m_node</span></tt> uninitialized.</td></tr>
|
||||
@@ -856,7 +856,7 @@ default constructor to leave <tt class="literal"><span class="pre">m_node</span>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="implementing-the-core-operations">
|
||||
<h3><a class="toc-backref" href="#id39" name="implementing-the-core-operations">Implementing the Core Operations</a></h3>
|
||||
<h3><a class="toc-backref" href="#id40" name="implementing-the-core-operations">Implementing the Core Operations</a></h3>
|
||||
<p>The last step is to implement the <a class="reference" href="#core-operations">core operations</a> required by
|
||||
the concepts we want our iterator to model. Referring to the
|
||||
<a class="reference" href="#core-operations">table</a>, we can see that the first three rows are applicable
|
||||
@@ -907,7 +907,7 @@ iterator! For a working example of its use, see <a class="reference" href="../e
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="a-constant-node-iterator">
|
||||
<h2><a class="toc-backref" href="#id40" name="a-constant-node-iterator">A constant <tt class="literal"><span class="pre">node_iterator</span></tt></a></h2>
|
||||
<h2><a class="toc-backref" href="#id41" name="a-constant-node-iterator">A constant <tt class="literal"><span class="pre">node_iterator</span></tt></a></h2>
|
||||
<div class="sidebar">
|
||||
<p class="sidebar-title">Constant and Mutable iterators</p>
|
||||
<p>The term <strong>mutable iterator</strong> means an iterator through which
|
||||
@@ -1008,7 +1008,7 @@ typedef node_iter<node_base const> node_const_iterator;
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="interoperability">
|
||||
<h2><a class="toc-backref" href="#id41" name="interoperability">Interoperability</a></h2>
|
||||
<h2><a class="toc-backref" href="#id42" name="interoperability">Interoperability</a></h2>
|
||||
<p>Our <tt class="literal"><span class="pre">const_node_iterator</span></tt> works perfectly well on its own, but
|
||||
taken together with <tt class="literal"><span class="pre">node_iterator</span></tt> it doesn't quite meet
|
||||
expectations. For example, we'd like to be able to pass a
|
||||
@@ -1020,7 +1020,7 @@ compare them for equality.</p>
|
||||
<p>This expected ability to use two different iterator types together
|
||||
is known as <a class="reference" href="new-iter-concepts.html#interoperable-iterators-lib-interoperable-iterators"><strong>interoperability</strong></a>. Achieving interoperability in
|
||||
our case is as simple as templatizing the <tt class="literal"><span class="pre">equal</span></tt> function and
|
||||
adding a templatized converting constructor <a class="footnote-reference" href="#broken" id="id14" name="id14"><sup>3</sup></a> <a class="footnote-reference" href="#random" id="id15" name="id15"><sup>4</sup></a>:</p>
|
||||
adding a templatized converting constructor <a class="footnote-reference" href="#broken" id="id15" name="id15"><sup>3</sup></a> <a class="footnote-reference" href="#random" id="id16" name="id16"><sup>4</sup></a>:</p>
|
||||
<pre class="literal-block">
|
||||
template <class Value>
|
||||
class node_iter
|
||||
@@ -1065,14 +1065,14 @@ typedef impl::node_iterator<node_base const> node_const_iterator;
|
||||
<table class="footnote" frame="void" id="broken" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id14" name="broken">[3]</a></td><td>If you're using an older compiler and it can't handle
|
||||
<tr><td class="label"><a class="fn-backref" href="#id15" name="broken">[3]</a></td><td>If you're using an older compiler and it can't handle
|
||||
this example, see the <a class="reference" href="../example/node_iterator2.hpp">example code</a> for workarounds.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="footnote" frame="void" id="random" rules="none">
|
||||
<colgroup><col class="label" /><col /></colgroup>
|
||||
<tbody valign="top">
|
||||
<tr><td class="label"><a class="fn-backref" href="#id15" name="random">[4]</a></td><td>If <tt class="literal"><span class="pre">node_iterator</span></tt> had been a <a class="reference" href="new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators">random access
|
||||
<tr><td class="label"><a class="fn-backref" href="#id16" name="random">[4]</a></td><td>If <tt class="literal"><span class="pre">node_iterator</span></tt> had been a <a class="reference" href="new-iter-concepts.html#random-access-traversal-iterators-lib-random-access-traversal-iterators">random access
|
||||
traversal iterator</a>, we'd have had to templatize its
|
||||
<tt class="literal"><span class="pre">distance_to</span></tt> function as well.</td></tr>
|
||||
</tbody>
|
||||
@@ -1081,7 +1081,7 @@ traversal iterator</a>, we'd have had to templatize its
|
||||
iterators <a class="reference" href="../example/node_iterator2.cpp">here</a>.</p>
|
||||
</div>
|
||||
<div class="section" id="telling-the-truth">
|
||||
<h2><a class="toc-backref" href="#id42" name="telling-the-truth">Telling the Truth</a></h2>
|
||||
<h2><a class="toc-backref" href="#id43" name="telling-the-truth">Telling the Truth</a></h2>
|
||||
<p>Now <tt class="literal"><span class="pre">node_iterator</span></tt> and <tt class="literal"><span class="pre">node_const_iterator</span></tt> behave exactly as
|
||||
you'd expect... almost. We can compare them and we can convert in
|
||||
one direction: from <tt class="literal"><span class="pre">node_iterator</span></tt> to <tt class="literal"><span class="pre">node_const_iterator</span></tt>.
|
||||
@@ -1119,7 +1119,7 @@ appropriate:</p>
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="wrap-up">
|
||||
<h2><a class="toc-backref" href="#id43" name="wrap-up">Wrap Up</a></h2>
|
||||
<h2><a class="toc-backref" href="#id44" name="wrap-up">Wrap Up</a></h2>
|
||||
<p>This concludes our <tt class="literal"><span class="pre">iterator_facade</span></tt> tutorial, but before you
|
||||
stop reading we urge you to take a look at <a class="reference" href="iterator_adaptor.html"><tt class="literal"><span class="pre">iterator_adaptor</span></tt></a>.
|
||||
There's another way to approach writing these iterators which might
|
||||
|
||||
@@ -993,9 +993,9 @@ otherwise.</p>
|
||||
</div>
|
||||
<div class="section" id="footnotes">
|
||||
<h1><a class="toc-backref" href="#id24" name="footnotes">Footnotes</a></h1>
|
||||
<p>The UnaryTypeTrait concept is defined in <a class="reference" href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1519.htm">n1519</a>; the LWG added the
|
||||
requirement that specializations are derived from their nested
|
||||
<tt class="literal"><span class="pre">::type</span></tt>.</p>
|
||||
<p>The UnaryTypeTrait concept is defined in <a class="reference" href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1519.htm">n1519</a>; the LWG is
|
||||
considering adding the requirement that specializations are derived
|
||||
from their nested <tt class="literal"><span class="pre">::type</span></tt>.</p>
|
||||
<!-- LocalWords: Abrahams Siek Witt const bool Sutter's WG int UL LI href Lvalue
|
||||
LocalWords: ReadableIterator WritableIterator SwappableIterator cv pre iter
|
||||
LocalWords: ConstantLvalueIterator MutableLvalueIterator CopyConstructible TR
|
||||
|
||||
@@ -784,9 +784,9 @@ where *category-to-traversal* is defined as follows
|
||||
|
||||
.. _UnaryTypeTrait: n1519_
|
||||
|
||||
The UnaryTypeTrait concept is defined in n1519_; the LWG added the
|
||||
requirement that specializations are derived from their nested
|
||||
``::type``.
|
||||
The UnaryTypeTrait concept is defined in n1519_; the LWG is
|
||||
considering adding the requirement that specializations are derived
|
||||
from their nested ``::type``.
|
||||
|
||||
.. _n1519: http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1519.htm
|
||||
|
||||
|
||||
Reference in new issue
Block a user