Some progress on indirect_iterator

[SVN r21710]
This commit is contained in:
Dave Abrahams
2004-01-13 23:03:18 +00:00
parent 736044938d
commit 0f8c236e9d
15 changed files with 524 additions and 127 deletions

View File

@ -57,7 +57,7 @@ texcrap = *.mpx *.log *.aux *.blg *-print.brf *-print.tex *.out
mpxcrap = mpxerr.tex mpxerr.pdf
generated = *.out *.[0-9] *.[0-9][0-9] *.bbl *.brf \
*.mp *.mmp *.pdf .depend *.ps TMP-*.pdf *.ftoc\
*.mp *.mmp *.pdf *.ps TMP-*.pdf *.ftoc\
${PRINTZIP} ${SLIDEZIP} ${GENFILE} ${DEPENDFILES} \
${texcrap} ${mpxcrap} ${CUTFOILS} $(strip $(wildcard *---*.tex))
@ -211,7 +211,7 @@ clean:
${RMRF} ${generated}
# ... Target: create dependencies
depend: .depend .depend-rst
depend: .depend-rst
# ... Target: dependency file (parse TEXFILES for multiinclude and includegraphics)
.depend: GNUmakefile ${TEXFILES}
@ -226,11 +226,11 @@ depend: .depend .depend-rst
${RMRF} $@
@for t in ${RSTSTEMS} ; do \
${ECHO} "Scanning $$t.rst"; \
${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /^\.\. include::\s+(.*)/ && print "$$target: $$1\n";}' $$t.html < $$t.rst >> $@; \
${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /^\.\. include::\s+(.*)/ && print "$$target: $$1\n";}' $$t.tex < $$t.rst >> $@; \
${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /^\.\. (include|image)::\s+(.*)/ && print "$$target: $$2\n";}' $$t.html < $$t.rst >> $@; \
${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /^\.\. (include|image)::\s+(.*)/ && print "$$target: $$2\n";}' $$t.tex < $$t.rst >> $@; \
done
# ... include dependency files
-include .depend
# -include .depend
-include .depend-rst

View File

@ -7,7 +7,7 @@
<title>Iterator Facade and Adaptor</title>
<meta name="author" content="David Abrahams, Jeremy Siek, Thomas Witt" />
<meta name="organization" content="Boost Consulting, Indiana University Open Systems Lab, University of Hanover Institute for Transport Railway Operation and Construction" />
<meta name="date" content="2004-01-12" />
<meta name="date" content="2004-01-13" />
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
@ -26,7 +26,7 @@
Lab</a>, University of Hanover <a class="last reference" href="http://www.ive.uni-hannover.de">Institute for Transport
Railway Operation and Construction</a></td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>2004-01-12</td></tr>
<td>2004-01-13</td></tr>
<tr class="field"><th class="docinfo-name">Number:</th><td class="field-body">This is a revised version of <a class="reference" href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1530.html">N1530</a>=03-0113, which was
accepted for Technical Report 1 by the C++ standard
committee's library working group.</td>
@ -802,8 +802,7 @@ Iterator</td>
<div class="section" id="iterator-facade-iterator-category">
<h3><a class="toc-backref" href="#id30" name="iterator-facade-iterator-category"><tt class="literal"><span class="pre">iterator_facade</span></tt> iterator category</a></h3>
<p>The <tt class="literal"><span class="pre">iterator_category</span></tt> member of <tt class="literal"><span class="pre">iterator_facade&lt;X,V,R,C,D&gt;</span></tt>
is a type which satisfies the following conditions:</p>
<blockquote>
satisfies the following conditions:</p>
<ul>
<li><p class="first">if <tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt> or
<tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::output_iterator_tag</span></tt>,
@ -845,7 +844,9 @@ convertible, and not to any more-derived traversal tag type.</p>
</ul>
</li>
</ul>
</blockquote>
<!-- 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) -->
</div>
<div class="section" id="iterator-facade-operations">
<h3><a class="toc-backref" href="#id31" name="iterator-facade-operations"><tt class="literal"><span class="pre">iterator_facade</span></tt> operations</a></h3>
@ -1410,37 +1411,72 @@ if (Difference is use_default)
else
typedef Difference difference_type;
</pre>
<p>If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is not <tt class="literal"><span class="pre">use_default</span></tt> then
<tt class="literal"><span class="pre">iterator_category</span></tt> is <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>. Otherwise
<tt class="literal"><span class="pre">iterator_category</span></tt> is a type convertible to the tag determined by
the following algorithm. Let <tt class="literal"><span class="pre">C</span></tt> be <tt class="literal"><span class="pre">traversal_category&lt;Iterator&gt;::type</span></tt>.</p>
<p><tt class="literal"><span class="pre">iterator_category</span></tt> satisfies the following conditions, where
<tt class="literal"><span class="pre">R</span></tt> is <tt class="literal"><span class="pre">reference</span></tt> and <tt class="literal"><span class="pre">V</span></tt> is <tt class="literal"><span class="pre">value_type</span></tt>, and 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&lt;Iterator&gt;::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>
<blockquote>
<ul>
<li><p class="first">if <tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt> or
<tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::output_iterator_tag</span></tt>,
<tt class="literal"><span class="pre">iterator_category</span></tt> is the same as <tt class="literal"><span class="pre">C</span></tt>.</p>
</li>
<li><p class="first">Otherwise, if <tt class="literal"><span class="pre">C</span></tt> is not convertible to
<tt class="literal"><span class="pre">incrementable_traversal_tag</span></tt>, the program is ill-formed</p>
</li>
<li><p class="first">Otherwise:</p>
<ul>
<li><p class="first"><tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to the iterator
category tag or tags given by the following algorithm, and
not to any more-derived iterator category tag or tags:</p>
<pre class="literal-block">
if (reference is a reference to value_type) then
if (C is convertible to random_access_traversal_tag) then
if (R is a reference type
&amp;&amp; C is convertible to forward_traversal_tag)
{
if (C is convertible to random_access_traversal_tag)
random_access_iterator_tag
else if (C is convertible to bidirectional_traversal_tag) then
else if (C is convertible to bidirectional_traversal_tag)
bidirectional_iterator_tag
else
forward_iterator_tag
}
else
{
if (C is convertible to single_pass_traversal_tag
&amp;&amp; R is convertible to V)
input_iterator_tag
else
C
}
</pre>
</li>
<li><p class="first"><tt class="literal"><span class="pre">iterator_traversal&lt;X&gt;::type</span></tt> is convertible to the most
derived traversal tag type to which <tt class="literal"><span class="pre">C</span></tt> is also
convertible, and not to any more-derived traversal tag type.</p>
</li>
</ul>
</li>
</ul>
<!-- 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) -->
</blockquote>
</div>
<div class="section" id="indirect-iterator-requirements">
<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 <tt class="literal"><span class="pre">Iterator</span></tt> argument shall meet the requirements of Readable
Iterator. The <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> argument shall be one of the
standard iterator tags or <tt class="literal"><span class="pre">use_default</span></tt>. If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>
is an iterator tag, the template parameter <tt class="literal"><span class="pre">Iterator</span></tt> argument shall
meet the requirements corresponding to the iterator tag.</p>
<p><tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> argument shall be <tt class="literal"><span class="pre">use_default</span></tt> or it
shall be convertible to one of the standard iterator or traversal
tags. If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is not <tt class="literal"><span class="pre">use_default</span></tt>, it shall
indicate the traversal category modeled by <tt class="literal"><span class="pre">Iterator</span></tt>. If</p>
<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 type
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt>, must be a valid expression
and must be convertible to <tt class="literal"><span class="pre">indirect_iterator::reference</span></tt>. Also
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt>, shall be valid
expression and convertible to <tt class="literal"><span class="pre">reference</span></tt>. Also
<tt class="literal"><span class="pre">indirect_iterator::reference</span></tt> must be convertible to
<tt class="literal"><span class="pre">indirect_iterator::value</span></tt>. There are further requirements on the
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt> if the <tt class="literal"><span class="pre">Value</span></tt> parameter
is not <tt class="literal"><span class="pre">use_default</span></tt>, as implied by the algorithm for deducing the
default for the <tt class="literal"><span class="pre">value_type</span></tt> member.</p>
<tt class="literal"><span class="pre">indirect_iterator::value</span></tt>. There are further requirements on
the <tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt> if the <tt class="literal"><span class="pre">Value</span></tt>
parameter is not <tt class="literal"><span class="pre">use_default</span></tt>, as implied by the algorithm for
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="#id46" name="indirect-iterator-models"><tt class="literal"><span class="pre">indirect_iterator</span></tt> models</a></h4>
@ -2436,7 +2472,6 @@ LocalWords: OtherIncrementable Coplien -->
<hr class="footer" />
<div class="footer">
<a class="reference" href="facade-and-adaptor.rst">View document source</a>.
Generated on: 2004-01-13 20:19 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>

View File

@ -0,0 +1,39 @@
* if ``C`` is convertible to ``std::input_iterator_tag`` or
``C`` is convertible to ``std::output_iterator_tag``,
``iterator_category`` is the same as ``C``.
* Otherwise, if ``C`` is not convertible to
``incrementable_traversal_tag``, the program is ill-formed
* Otherwise:
- ``iterator_category`` is convertible to the iterator
category tag or tags given by the following algorithm, and
not to any more-derived iterator category tag or tags::
if (R is a reference type
&& C is convertible to forward_traversal_tag)
{
if (C is convertible to random_access_traversal_tag)
random_access_iterator_tag
else if (C is convertible to bidirectional_traversal_tag)
bidirectional_iterator_tag
else
forward_iterator_tag
}
else
{
if (C is convertible to single_pass_traversal_tag
&& R is convertible to V)
input_iterator_tag
else
C
}
- ``iterator_traversal<X>::type`` is convertible to the most
derived traversal tag type to which ``C`` is also
convertible, and not to any more-derived traversal tag type.
.. 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)

View File

@ -140,6 +140,9 @@ underlying sequence. This component also replaces the old
<div class="section" id="traits">
<h2><a class="toc-backref" href="#id10" name="traits">Traits</a></h2>
<ul class="simple">
<li><a class="reference" href="pointee.html"><tt class="literal"><span class="pre">pointee.hpp</span></tt></a>: Provides the capability to deduce the referent types
of pointers, smart pointers and iterators in generic code. Used
in <tt class="literal"><span class="pre">indirect_iterator</span></tt>.</li>
<li><a class="reference" href="iterator_traits.html"><tt class="literal"><span class="pre">iterator_traits.hpp</span></tt></a>: Provides <a class="reference" href="../../mpl/doc/index.html">MPL</a>-compatible metafunctions which
retrieve an iterator's traits. Also corrects for the deficiencies
of broken implementations of <tt class="literal"><span class="pre">std::iterator_traits</span></tt>.</li>
@ -226,7 +229,7 @@ LocalWords: TraversalTag typename lvalues DWA Hmm JGS -->
<hr class="footer" />
<div class="footer">
<a class="reference" href="index.rst">View document source</a>.
Generated on: 2004-01-13 14:25 UTC.
Generated on: 2004-01-13.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>

View File

@ -169,6 +169,10 @@ iterator templates based on the Boost `iterator facade and adaptor`_.
Traits
------
* |pointee|_: Provides the capability to deduce the referent types
of pointers, smart pointers and iterators in generic code. Used
in |indirect|.
* |iterator_traits|_: Provides MPL_\ -compatible metafunctions which
retrieve an iterator's traits. Also corrects for the deficiencies
of broken implementations of ``std::iterator_traits``.
@ -176,6 +180,9 @@ Traits
* |interoperable|_: Provides an MPL_\ -compatible metafunction for
testing iterator interoperability
.. |pointee| replace:: ``pointee.hpp``
.. _pointee: pointee.html
.. |iterator_traits| replace:: ``iterator_traits.hpp``
.. _iterator_traits: iterator_traits.html

View File

@ -125,37 +125,72 @@ if (Difference is use_default)
else
typedef Difference difference_type;
</pre>
<p>If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is not <tt class="literal"><span class="pre">use_default</span></tt> then
<tt class="literal"><span class="pre">iterator_category</span></tt> is <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>. Otherwise
<tt class="literal"><span class="pre">iterator_category</span></tt> is a type convertible to the tag determined by
the following algorithm. Let <tt class="literal"><span class="pre">C</span></tt> be <tt class="literal"><span class="pre">traversal_category&lt;Iterator&gt;::type</span></tt>.</p>
<p><tt class="literal"><span class="pre">iterator_category</span></tt> satisfies the following conditions, where
<tt class="literal"><span class="pre">R</span></tt> is <tt class="literal"><span class="pre">reference</span></tt> and <tt class="literal"><span class="pre">V</span></tt> is <tt class="literal"><span class="pre">value_type</span></tt>, and 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&lt;Iterator&gt;::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>
<blockquote>
<ul>
<li><p class="first">if <tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt> or
<tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::output_iterator_tag</span></tt>,
<tt class="literal"><span class="pre">iterator_category</span></tt> is the same as <tt class="literal"><span class="pre">C</span></tt>.</p>
</li>
<li><p class="first">Otherwise, if <tt class="literal"><span class="pre">C</span></tt> is not convertible to
<tt class="literal"><span class="pre">incrementable_traversal_tag</span></tt>, the program is ill-formed</p>
</li>
<li><p class="first">Otherwise:</p>
<ul>
<li><p class="first"><tt class="literal"><span class="pre">iterator_category</span></tt> is convertible to the iterator
category tag or tags given by the following algorithm, and
not to any more-derived iterator category tag or tags:</p>
<pre class="literal-block">
if (reference is a reference to value_type) then
if (C is convertible to random_access_traversal_tag) then
if (R is a reference type
&amp;&amp; C is convertible to forward_traversal_tag)
{
if (C is convertible to random_access_traversal_tag)
random_access_iterator_tag
else if (C is convertible to bidirectional_traversal_tag) then
else if (C is convertible to bidirectional_traversal_tag)
bidirectional_iterator_tag
else
forward_iterator_tag
}
else
{
if (C is convertible to single_pass_traversal_tag
&amp;&amp; R is convertible to V)
input_iterator_tag
else
C
}
</pre>
</li>
<li><p class="first"><tt class="literal"><span class="pre">iterator_traversal&lt;X&gt;::type</span></tt> is convertible to the most
derived traversal tag type to which <tt class="literal"><span class="pre">C</span></tt> is also
convertible, and not to any more-derived traversal tag type.</p>
</li>
</ul>
</li>
</ul>
<!-- 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) -->
</blockquote>
</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>
<p>The <tt class="literal"><span class="pre">Iterator</span></tt> argument shall meet the requirements of Readable
Iterator. The <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> argument shall be one of the
standard iterator tags or <tt class="literal"><span class="pre">use_default</span></tt>. If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt>
is an iterator tag, the template parameter <tt class="literal"><span class="pre">Iterator</span></tt> argument shall
meet the requirements corresponding to the iterator tag.</p>
<p><tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> argument shall be <tt class="literal"><span class="pre">use_default</span></tt> or it
shall be convertible to one of the standard iterator or traversal
tags. If <tt class="literal"><span class="pre">CategoryOrTraversal</span></tt> is not <tt class="literal"><span class="pre">use_default</span></tt>, it shall
indicate the traversal category modeled by <tt class="literal"><span class="pre">Iterator</span></tt>. If</p>
<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 type
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt>, must be a valid expression
and must be convertible to <tt class="literal"><span class="pre">indirect_iterator::reference</span></tt>. Also
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt>, shall be valid
expression and convertible to <tt class="literal"><span class="pre">reference</span></tt>. Also
<tt class="literal"><span class="pre">indirect_iterator::reference</span></tt> must be convertible to
<tt class="literal"><span class="pre">indirect_iterator::value</span></tt>. There are further requirements on the
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt> if the <tt class="literal"><span class="pre">Value</span></tt> parameter
is not <tt class="literal"><span class="pre">use_default</span></tt>, as implied by the algorithm for deducing the
default for the <tt class="literal"><span class="pre">value_type</span></tt> member.</p>
<tt class="literal"><span class="pre">indirect_iterator::value</span></tt>. There are further requirements on
the <tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::value_type</span></tt> if the <tt class="literal"><span class="pre">Value</span></tt>
parameter is not <tt class="literal"><span class="pre">use_default</span></tt>, as implied by the algorithm for
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">
<h1><a class="toc-backref" href="#id4" name="indirect-iterator-models"><tt class="literal"><span class="pre">indirect_iterator</span></tt> models</a></h1>
@ -327,7 +362,6 @@ a,b,c,d,e,f,g,
<hr class="footer" />
<div class="footer">
<a class="reference" href="indirect_iterator.rst">View document source</a>.
Generated on: 2004-01-13 19:54 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>

View File

@ -66,52 +66,34 @@ following pseudo-code. We use the abbreviation
else
typedef Difference difference_type;
``iterator_category`` satisfies the following conditions, where
``R`` is ``reference`` and ``V`` is ``value_type``, and where: if
``CategoryOrTraversal`` is ``use_default``, ``C`` is
``iterator_traversal<Iterator>::type`` and otherwise ``C`` is
``CategoryOrTraversal``:
If ``CategoryOrTraversal`` is not ``use_default`` then
``iterator_category`` is ``CategoryOrTraversal``. Otherwise
``iterator_category`` is a type convertible to the tag determined by
the following algorithm. Let ``C`` be ``traversal_category<Iterator>::type``.
::
if (reference is a reference to value_type) then
if (C is convertible to random_access_traversal_tag) then
random_access_iterator_tag
else if (C is convertible to bidirectional_traversal_tag) then
bidirectional_iterator_tag
else
forward_iterator_tag
else
input_iterator_tag
.. include:: facade_iterator_category.rst
``indirect_iterator`` requirements
..................................
The ``Iterator`` argument shall meet the requirements of Readable
Iterator. The ``CategoryOrTraversal`` argument shall be one of the
standard iterator tags or ``use_default``. If ``CategoryOrTraversal``
is an iterator tag, the template parameter ``Iterator`` argument shall
meet the requirements corresponding to the iterator tag.
The expression ``*v``, where ``v`` is an object of type
``iterator_traits<Iterator>::value_type``, must be a valid expression
and must be convertible to ``indirect_iterator::reference``. Also
``indirect_iterator::reference`` must be convertible to
``indirect_iterator::value``. There are further requirements on the
``iterator_traits<Iterator>::value_type`` if the ``Value`` parameter
is not ``use_default``, as implied by the algorithm for deducing the
default for the ``value_type`` member.
``iterator_traits<Iterator>::value_type``, shall be valid
expression and convertible to ``reference``. [Note: there are
further requirements on the
``iterator_traits<Iterator>::value_type`` if the ``Value``
parameter is not ``use_default``, as implied by the algorithm for
deducing the default for the ``value_type`` member.]
``indirect_iterator`` models
............................
If ``CategoryOrTraversal`` is a standard iterator tag,
``indirect_iterator`` is a model of the iterator concept corresponding
to the tag, otherwise ``indirect_iterator`` satisfies the requirements
of the most refined standard traversal concept that is satisfied by
the ``Iterator`` argument.
``indirect_iterator`` is a model of the iterator concept
corresponding to the tag. Otherwise, ``indirect_iterator``
satisfies the requirements of the most refined standard traversal
concept that is satisfied by the ``Iterator`` argument.
``indirect_iterator`` models Readable Iterator. If
``indirect_iterator::reference(*v) = t`` is a valid expression (where

29
doc/indirect_reference_ref.rst Executable file
View File

@ -0,0 +1,29 @@
.. 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)
::
template <class Dereferenceable>
struct indirect_reference
{
typedef /* see below */ type;
};
:Requires: For an object ``x`` of type ``Dereferenceable``, ``*x``
is well-formed. If ``++x`` is ill-formed it shall neither be
ambiguous nor shall it violate access control, and
``pointee<Dereferenceable>::type&`` shall be well-formed.
Otherwise ``iterator_traits<Dereferenceable>::reference`` shall
be well formed. [Note: These requirements need not apply to
explicit or partial specializations of ``indirect_reference``]
``type`` is determined according to the following algorithm, where
``x`` is an object of type ``Dereferenceable``::
if ( ++x is ill-formed )
return ``pointee<Dereferenceable>::type&``
else
std::iterator_traits<Dereferenceable>::value_type

View File

@ -466,8 +466,7 @@ Iterator</td>
<div class="section" id="iterator-facade-iterator-category">
<h2><a class="toc-backref" href="#id27" name="iterator-facade-iterator-category"><tt class="literal"><span class="pre">iterator_facade</span></tt> iterator category</a></h2>
<p>The <tt class="literal"><span class="pre">iterator_category</span></tt> member of <tt class="literal"><span class="pre">iterator_facade&lt;X,V,R,C,D&gt;</span></tt>
is a type which satisfies the following conditions:</p>
<blockquote>
satisfies the following conditions:</p>
<ul>
<li><p class="first">if <tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::input_iterator_tag</span></tt> or
<tt class="literal"><span class="pre">C</span></tt> is convertible to <tt class="literal"><span class="pre">std::output_iterator_tag</span></tt>,
@ -509,7 +508,9 @@ convertible, and not to any more-derived traversal tag type.</p>
</ul>
</li>
</ul>
</blockquote>
<!-- 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) -->
</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>
@ -1132,7 +1133,6 @@ even be superior.</p>
<hr class="footer" />
<div class="footer">
<a class="reference" href="iterator_facade.rst">View document source</a>.
Generated on: 2004-01-13 18:05 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>

View File

@ -173,44 +173,9 @@ interoperable with ``X``.
-------------------------------------
The ``iterator_category`` member of ``iterator_facade<X,V,R,C,D>``
is a type which satisfies the following conditions:
* if ``C`` is convertible to ``std::input_iterator_tag`` or
``C`` is convertible to ``std::output_iterator_tag``,
``iterator_category`` is the same as ``C``.
* Otherwise, if ``C`` is not convertible to
``incrementable_traversal_tag``, the program is ill-formed
* Otherwise:
- ``iterator_category`` is convertible to the iterator
category tag or tags given by the following algorithm, and
not to any more-derived iterator category tag or tags::
if (R is a reference type
&& C is convertible to forward_traversal_tag)
{
if (C is convertible to random_access_traversal_tag)
random_access_iterator_tag
else if (C is convertible to bidirectional_traversal_tag)
bidirectional_iterator_tag
else
forward_iterator_tag
}
else
{
if (C is convertible to single_pass_traversal_tag
&& R is convertible to V)
input_iterator_tag
else
C
}
- ``iterator_traversal<X>::type`` is convertible to the most
derived traversal tag type to which ``C`` is also
convertible, and not to any more-derived traversal tag type.
satisfies the following conditions:
.. include:: facade_iterator_category.rst
``iterator_facade`` operations
------------------------------

180
doc/pointee.html Executable file
View File

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.1: http://docutils.sourceforge.net/" />
<title>pointee and indirect_reference</title>
<meta name="author" content="David Abrahams" />
<meta name="organization" content="Boost Consulting" />
<meta name="date" content="2004-01-13" />
<meta name="copyright" content="Copyright David Abrahams 2004. All rights reserved" />
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
<div class="document" id="pointee-and-indirect-reference">
<h1 class="title"><tt class="literal"><span class="pre">pointee</span></tt> and <tt class="literal"><span class="pre">indirect_reference</span></tt></h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>David Abrahams</td></tr>
<tr><th class="docinfo-name">Contact:</th>
<td><a class="first reference" href="mailto:dave&#64;boost-consulting.com">dave&#64;boost-consulting.com</a>, <a class="reference" href="mailto:jsiek&#64;osl.iu.edu">jsiek&#64;osl.iu.edu</a>, <a class="last reference" href="mailto:witt&#64;ive.uni-hannover.de">witt&#64;ive.uni-hannover.de</a></td></tr>
<tr><th class="docinfo-name">Organization:</th>
<td><a class="first last reference" href="http://www.boost-consulting.com">Boost Consulting</a></td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>2004-01-13</td></tr>
<tr><th class="docinfo-name">Copyright:</th>
<td>Copyright David Abrahams 2004. All rights reserved</td></tr>
</tbody>
</table>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">abstract:</th><td class="field-body">Provides the capability to deduce the referent types of
pointers, smart pointers and iterators in generic code.</td>
</tr>
</tbody>
</table>
<div class="section" id="overview">
<h1><a name="overview">Overview</a></h1>
<p>Have you ever wanted to write a generic function that can operate
on any kind of dereferenceable object? If you have, you've
probably run into the problem of how to determine the type that the
object &quot;points at&quot;:</p>
<pre class="literal-block">
template &lt;class Dereferenceable&gt;
void f(Dereferenceable p)
{
<em>what-goes-here?</em> value = *p;
...
}
</pre>
<div class="section" id="pointee">
<h2><a name="pointee"><tt class="literal"><span class="pre">pointee</span></tt></a></h2>
<p>It turns out to be impossible to come up with a fully-general
algorithm to do determine <em>what-goes-here</em> directly, but it is
possible to require that <tt class="literal"><span class="pre">pointee&lt;Dereferenceable&gt;::type</span></tt> is
correct. Naturally, <tt class="literal"><span class="pre">pointee</span></tt> has the same difficulty: it can't
determine the appropriate <tt class="literal"><span class="pre">::type</span></tt> reliably for all
<tt class="literal"><span class="pre">Dereferenceable</span></tt>s, but it makes very good guesses (it works
for all pointers, standard and boost smart pointers, and
iterators), and when it guesses wrongly, it can be specialized as
neccessary:</p>
<pre class="literal-block">
namespace boost
{
template &lt;class T&gt;
struct pointee&lt;third_party_lib::smart_pointer&lt;T&gt; &gt;
{
typedef T type;
};
}
</pre>
</div>
<div class="section" id="indirect-reference">
<h2><a name="indirect-reference"><tt class="literal"><span class="pre">indirect_reference</span></tt></a></h2>
<p><tt class="literal"><span class="pre">indirect_reference&lt;T&gt;::type</span></tt> is rather more specialized than
<tt class="literal"><span class="pre">pointee</span></tt>, and is meant to be used to forward the result of
dereferencing an object of its argument type. Most dereferenceable
types just return a reference to their pointee, but some return
proxy references or return the pointee by value. When that
information is needed, call on <tt class="literal"><span class="pre">indirect_reference</span></tt>.</p>
<p>Both of these templates are essential to the correct functioning of
<a class="reference" href="indirect_iterator.html"><tt class="literal"><span class="pre">indirect_iterator</span></tt></a>.</p>
</div>
</div>
<div class="section" id="reference">
<h1><a name="reference">Reference</a></h1>
<div class="section" id="id1">
<h2><a name="id1"><tt class="literal"><span class="pre">pointee</span></tt></a></h2>
<!-- 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) -->
<pre class="literal-block">
template &lt;class Dereferenceable&gt;
struct pointee
{
typedef /* see below */ type;
};
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Requires:</th><td class="field-body">For an object <tt class="literal"><span class="pre">x</span></tt> of type <tt class="literal"><span class="pre">Dereferenceable</span></tt>, <tt class="literal"><span class="pre">*x</span></tt>
is well-formed. If <tt class="literal"><span class="pre">++x</span></tt> is ill-formed it shall neither be
ambiguous nor shall it violate access control, and
<tt class="literal"><span class="pre">Dereferenceable::element_type</span></tt> shall be an accessible type.
Otherwise <tt class="literal"><span class="pre">iterator_traits&lt;Dereferenceable&gt;::value_type</span></tt> shall
be well formed. [Note: These requirements need not apply to
explicit or partial specializations of <tt class="literal"><span class="pre">pointee</span></tt>]</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">type</span></tt> is determined according to the following algorithm, where
<tt class="literal"><span class="pre">x</span></tt> is an object of type <tt class="literal"><span class="pre">Dereferenceable</span></tt>:</p>
<pre class="literal-block">
if ( ++x is ill-formed )
{
return ``Dereferenceable::element_type``
}
else if (``*x`` is a mutable reference to
std::iterator_traits&lt;Dereferenceable&gt;::value_type)
{
return iterator_traits&lt;Dereferenceable&gt;::value_type
}
else
{
return iterator_traits&lt;Dereferenceable&gt;::value_type const
}
</pre>
</div>
<div class="section" id="id2">
<h2><a name="id2"><tt class="literal"><span class="pre">indirect_reference</span></tt></a></h2>
<!-- 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) -->
<pre class="literal-block">
template &lt;class Dereferenceable&gt;
struct indirect_reference
{
typedef /* see below */ type;
};
</pre>
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Requires:</th><td class="field-body">For an object <tt class="literal"><span class="pre">x</span></tt> of type <tt class="literal"><span class="pre">Dereferenceable</span></tt>, <tt class="literal"><span class="pre">*x</span></tt>
is well-formed. If <tt class="literal"><span class="pre">++x</span></tt> is ill-formed it shall neither be
ambiguous nor shall it violate access control, and
<tt class="literal"><span class="pre">pointee&lt;Dereferenceable&gt;::type&amp;</span></tt> shall be well-formed.
Otherwise <tt class="literal"><span class="pre">iterator_traits&lt;Dereferenceable&gt;::reference</span></tt> shall
be well formed. [Note: These requirements need not apply to
explicit or partial specializations of <tt class="literal"><span class="pre">indirect_reference</span></tt>]</td>
</tr>
</tbody>
</table>
<p><tt class="literal"><span class="pre">type</span></tt> is determined according to the following algorithm, where
<tt class="literal"><span class="pre">x</span></tt> is an object of type <tt class="literal"><span class="pre">Dereferenceable</span></tt>:</p>
<pre class="literal-block">
if ( ++x is ill-formed )
return ``pointee&lt;Dereferenceable&gt;::type&amp;``
else
std::iterator_traits&lt;Dereferenceable&gt;::value_type
</pre>
</div>
</div>
</div>
<hr class="footer" />
<div class="footer">
<a class="reference" href="pointee.rst">View document source</a>.
Generated on: 2004-01-13.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
</body>
</html>

84
doc/pointee.rst Executable file
View File

@ -0,0 +1,84 @@
++++++++++++++++++++++++++++++++++++++++
``pointee`` and ``indirect_reference``
++++++++++++++++++++++++++++++++++++++++
:Author: David Abrahams
:Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de
:organization: `Boost Consulting`_
:date: $Date$
:copyright: Copyright David Abrahams 2004. All rights reserved
.. _`Boost Consulting`: http://www.boost-consulting.com
:abstract: Provides the capability to deduce the referent types of
pointers, smart pointers and iterators in generic code.
Overview
========
Have you ever wanted to write a generic function that can operate
on any kind of dereferenceable object? If you have, you've
probably run into the problem of how to determine the type that the
object "points at":
.. parsed-literal::
template <class Dereferenceable>
void f(Dereferenceable p)
{
*what-goes-here?* value = \*p;
...
}
``pointee``
-----------
It turns out to be impossible to come up with a fully-general
algorithm to do determine *what-goes-here* directly, but it is
possible to require that ``pointee<Dereferenceable>::type`` is
correct. Naturally, ``pointee`` has the same difficulty: it can't
determine the appropriate ``::type`` reliably for all
``Dereferenceable``\ s, but it makes very good guesses (it works
for all pointers, standard and boost smart pointers, and
iterators), and when it guesses wrongly, it can be specialized as
neccessary::
namespace boost
{
template <class T>
struct pointee<third_party_lib::smart_pointer<T> >
{
typedef T type;
};
}
``indirect_reference``
----------------------
``indirect_reference<T>::type`` is rather more specialized than
``pointee``, and is meant to be used to forward the result of
dereferencing an object of its argument type. Most dereferenceable
types just return a reference to their pointee, but some return
proxy references or return the pointee by value. When that
information is needed, call on ``indirect_reference``.
Both of these templates are essential to the correct functioning of
|indirect_iterator|_.
.. |indirect_iterator| replace:: ``indirect_iterator``
.. _indirect_iterator: indirect_iterator.html
Reference
=========
``pointee``
-----------
.. include:: pointee_ref.rst
``indirect_reference``
----------------------
.. include:: indirect_reference_ref.rst

38
doc/pointee_ref.rst Executable file
View File

@ -0,0 +1,38 @@
.. 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)
::
template <class Dereferenceable>
struct pointee
{
typedef /* see below */ type;
};
:Requires: For an object ``x`` of type ``Dereferenceable``, ``*x``
is well-formed. If ``++x`` is ill-formed it shall neither be
ambiguous nor shall it violate access control, and
``Dereferenceable::element_type`` shall be an accessible type.
Otherwise ``iterator_traits<Dereferenceable>::value_type`` shall
be well formed. [Note: These requirements need not apply to
explicit or partial specializations of ``pointee``]
``type`` is determined according to the following algorithm, where
``x`` is an object of type ``Dereferenceable``::
if ( ++x is ill-formed )
{
return ``Dereferenceable::element_type``
}
else if (``*x`` is a mutable reference to
std::iterator_traits<Dereferenceable>::value_type)
{
return iterator_traits<Dereferenceable>::value_type
}
else
{
return iterator_traits<Dereferenceable>::value_type const
}

View File

@ -1,7 +1,7 @@
#!/bin/sh
PYTHONPATH="c:/src/docutils/docutils;c:/src/docutils/docutils/extras"
export PYTHONPATH
python c:/src/docutils/docutils/tools/html.py -gdts $1 `echo $1 | sed 's/\(.*\)\..*/\1.html/'`
python c:/src/docutils/docutils/tools/html.py -gs $1 `echo $1 | sed 's/\(.*\)\..*/\1.html/'`

View File

@ -9,6 +9,7 @@ sources = [
'function_output_iterator.rst',
'index.rst',
'indirect_iterator.rst',
'pointee.rst',
'iterator_adaptor.rst',
'iterator_facade.rst',
'new-iter-concepts.rst',