resolved some issues with counting_iterator

[SVN r21639]
This commit is contained in:
Jeremy Siek
2004-01-12 19:01:57 +00:00
parent b2407b0191
commit 6085e03da0
6 changed files with 88 additions and 39 deletions

View File

@ -63,6 +63,12 @@ template <
class counting_iterator
{
public:
typedef Incrementable value_type;
typedef const Incrementable& reference;
typedef const Incrementable* pointer;
typedef /* see below */ difference_type;
typedef /* see below */ iterator_category;
counting_iterator();
counting_iterator(counting_iterator const& rhs);
explicit counting_iterator(Incrementable x);
@ -74,6 +80,12 @@ class counting_iterator
Incrementable m_inc; // exposition
};
</pre>
<p>If the <tt class="literal"><span class="pre">Diference</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 implementation defined signed
integral type.</p>
<p>The member <tt class="literal"><span class="pre">iterator_category</span></tt> is a type that satisfies the
requirements of the concepts modeled by the <tt class="literal"><span class="pre">counting_iterator</span></tt> as
specified in the models section.</p>
<dl>
<dt>[<em>Note:</em> implementers are encouraged to provide an implementation of</dt>
<dd><tt class="literal"><span class="pre">distance_to</span></tt> and a <tt class="literal"><span class="pre">difference_type</span></tt> that avoids overflows in
@ -83,27 +95,28 @@ the cases when the <tt class="literal"><span class="pre">Incrementable</span></t
<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>
<p>The <tt class="literal"><span class="pre">Incrementable</span></tt> type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
an implementation defined signed integral type.</p>
Constructible, and Assignable.</p>
</div>
<div class="section" id="counting-iterator-models">
<h1><a class="toc-backref" href="#id4" name="counting-iterator-models"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></h1>
<p><tt class="literal"><span class="pre">counting_iterator</span></tt> models Readable Lvalue Iterator.</p>
<p>Furthermore, if you wish to create a counting iterator that is a Forward
Traversal Iterator, then the following expressions must be valid:</p>
<p>Furthermore, if you wish to create a counting iterator that is a
Forward Traversal Iterator and also Forward Iterator, then the
following expressions must be valid:</p>
<pre class="literal-block">
Incrementable i, j;
++i // pre-increment
i == j // operator equal
</pre>
<p>If you wish to create a counting iterator that is a
Bidirectional Traversal Iterator, then pre-decrement is also required:</p>
<p>If you wish to create a counting iterator that is a Bidirectional
Traversal Iterator and also Bidirectional Iterator, then pre-decrement
is also required:</p>
<pre class="literal-block">
--i
</pre>
<p>If you wish to create a counting iterator that is a Random Access
Traversal Iterator, then these additional expressions are also
required:</p>
Traversal Iterator and also Random Access Iterator, then these
additional expressions are also required:</p>
<pre class="literal-block">
counting_iterator::difference_type n;
i += n
@ -235,7 +248,7 @@ indirectly printing out the numbers from 0 to 7
<hr class="footer"/>
<div class="footer">
<a class="reference" href="counting_iterator.rst">View document source</a>.
Generated on: 2004-01-12 16:05 UTC.
Generated on: 2004-01-12 19:01 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

@ -8,6 +8,12 @@
class counting_iterator
{
public:
typedef Incrementable value_type;
typedef const Incrementable& reference;
typedef const Incrementable* pointer;
typedef /* see below */ difference_type;
typedef /* see below */ iterator_category;
counting_iterator();
counting_iterator(counting_iterator const& rhs);
explicit counting_iterator(Incrementable x);
@ -20,6 +26,15 @@
};
If the ``Diference`` argument is ``use_default`` then the
``difference_type`` member is an implementation defined signed
integral type.
The member ``iterator_category`` is a type that satisfies the
requirements of the concepts modeled by the ``counting_iterator`` as
specified in the models section.
[*Note:* implementers are encouraged to provide an implementation of
``distance_to`` and a ``difference_type`` that avoids overflows in
the cases when the ``Incrementable`` type is a numeric type.]
@ -28,8 +43,7 @@
..................................
The ``Incrementable`` type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
an implementation defined signed integral type.
Constructible, and Assignable.
``counting_iterator`` models
@ -37,21 +51,23 @@ an implementation defined signed integral type.
``counting_iterator`` models Readable Lvalue Iterator.
Furthermore, if you wish to create a counting iterator that is a Forward
Traversal Iterator, then the following expressions must be valid::
Furthermore, if you wish to create a counting iterator that is a
Forward Traversal Iterator and also Forward Iterator, then the
following expressions must be valid::
Incrementable i, j;
++i // pre-increment
i == j // operator equal
If you wish to create a counting iterator that is a
Bidirectional Traversal Iterator, then pre-decrement is also required::
If you wish to create a counting iterator that is a Bidirectional
Traversal Iterator and also Bidirectional Iterator, then pre-decrement
is also required::
--i
If you wish to create a counting iterator that is a Random Access
Traversal Iterator, then these additional expressions are also
required::
Traversal Iterator and also Random Access Iterator, then these
additional expressions are also required::
counting_iterator::difference_type n;
i += n

View File

@ -1327,9 +1327,9 @@ if (Difference is use_default)
else
typedef Difference difference_type;
</pre>
<p>The member <tt class="literal"><span class="pre">indirect_iterator::iterator_category</span></tt> is a type that
satisfies the requirements of the concepts modeled by the indirect
iterator as specified in the models section.</p>
<p>The member <tt class="literal"><span class="pre">iterator_category</span></tt> is a type that satisfies the
requirements of the concepts modeled by the <tt class="literal"><span class="pre">indirect_iterator</span></tt> as
specified in the models section.</p>
</div>
<div class="section" id="indirect-iterator-requirements">
<h4><a class="toc-backref" href="#id43" name="indirect-iterator-requirements"><tt class="literal"><span class="pre">indirect_iterator</span></tt> requirements</a></h4>
@ -2061,6 +2061,12 @@ template &lt;
class counting_iterator
{
public:
typedef Incrementable value_type;
typedef const Incrementable&amp; reference;
typedef const Incrementable* pointer;
typedef /* see below */ difference_type;
typedef /* see below */ iterator_category;
counting_iterator();
counting_iterator(counting_iterator const&amp; rhs);
explicit counting_iterator(Incrementable x);
@ -2072,6 +2078,12 @@ class counting_iterator
Incrementable m_inc; // exposition
};
</pre>
<p>If the <tt class="literal"><span class="pre">Diference</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 implementation defined signed
integral type.</p>
<p>The member <tt class="literal"><span class="pre">iterator_category</span></tt> is a type that satisfies the
requirements of the concepts modeled by the <tt class="literal"><span class="pre">counting_iterator</span></tt> as
specified in the models section.</p>
<dl>
<dt>[<em>Note:</em> implementers are encouraged to provide an implementation of</dt>
<dd><tt class="literal"><span class="pre">distance_to</span></tt> and a <tt class="literal"><span class="pre">difference_type</span></tt> that avoids overflows in
@ -2081,27 +2093,28 @@ the cases when the <tt class="literal"><span class="pre">Incrementable</span></t
<div class="section" id="counting-iterator-requirements">
<h4><a class="toc-backref" href="#id63" 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> type must be Default Constructible, Copy
Constructible, and Assignable. The default distance is
an implementation defined signed integral type.</p>
Constructible, and Assignable.</p>
</div>
<div class="section" id="counting-iterator-models">
<h4><a class="toc-backref" href="#id64" name="counting-iterator-models"><tt class="literal"><span class="pre">counting_iterator</span></tt> models</a></h4>
<p><tt class="literal"><span class="pre">counting_iterator</span></tt> models Readable Lvalue Iterator.</p>
<p>Furthermore, if you wish to create a counting iterator that is a Forward
Traversal Iterator, then the following expressions must be valid:</p>
<p>Furthermore, if you wish to create a counting iterator that is a
Forward Traversal Iterator and also Forward Iterator, then the
following expressions must be valid:</p>
<pre class="literal-block">
Incrementable i, j;
++i // pre-increment
i == j // operator equal
</pre>
<p>If you wish to create a counting iterator that is a
Bidirectional Traversal Iterator, then pre-decrement is also required:</p>
<p>If you wish to create a counting iterator that is a Bidirectional
Traversal Iterator and also Bidirectional Iterator, then pre-decrement
is also required:</p>
<pre class="literal-block">
--i
</pre>
<p>If you wish to create a counting iterator that is a Random Access
Traversal Iterator, then these additional expressions are also
required:</p>
Traversal Iterator and also Random Access Iterator, then these
additional expressions are also required:</p>
<pre class="literal-block">
counting_iterator::difference_type n;
i += n
@ -2308,7 +2321,7 @@ 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-12 18:37 UTC.
Generated on: 2004-01-12 19:01 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

@ -125,9 +125,9 @@ if (Difference is use_default)
else
typedef Difference difference_type;
</pre>
<p>The member <tt class="literal"><span class="pre">indirect_iterator::iterator_category</span></tt> is a type that
satisfies the requirements of the concepts modeled by the indirect
iterator as specified in the models section.</p>
<p>The member <tt class="literal"><span class="pre">iterator_category</span></tt> is a type that satisfies the
requirements of the concepts modeled by the <tt class="literal"><span class="pre">indirect_iterator</span></tt> as
specified in the models section.</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>
@ -315,7 +315,7 @@ 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-12 16:04 UTC.
Generated on: 2004-01-12 19:01 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

@ -67,9 +67,9 @@ following pseudo-code. We use the abbreviation
typedef Difference difference_type;
The member ``indirect_iterator::iterator_category`` is a type that
satisfies the requirements of the concepts modeled by the indirect
iterator as specified in the models section.
The member ``iterator_category`` is a type that satisfies the
requirements of the concepts modeled by the ``indirect_iterator`` as
specified in the models section.
``indirect_iterator`` requirements

View File

@ -271,7 +271,11 @@ The description of Counting iterator is unclear. "The counting iterator adaptor
dereference by returning a reference to the base object. The other operations are implemented by
the base m_iterator, as per the inheritance from iterator_adaptor."
:Proposed resolution: **Needs work** (Jeremy) Reword.
:Proposed resolution:
Change the introduction to: ``counting_iterator`` adapts an
arithmetic type, such as ``int``, by adding an ``operator*`` that
returns the current value of the object.
9.14 Counting_iterator's difference type
@ -290,8 +294,11 @@ I'm not sure what this means. The user provides a template argument named Differ
there's no difference_type. I assume this is just a glitch in the wording. But if implementors are
encouraged to ignore this argument if it won't work right, why is it there?
:Proposed resolution: **Needs work** (Jeremy)
Reword.
:Proposed resolution:
The ``difference_type`` was inherited from ``iterator_adaptor``.
However, we've removed the explicit inheritance, so explicit typedefs have
been added.
9.15 How to detect lvalueness?