removed constraints on reference from Readable Iterator

[SVN r21641]
This commit is contained in:
Jeremy Siek
2004-01-12 19:54:57 +00:00
parent db9d88ad7b
commit 21381f3fa7
3 changed files with 38 additions and 47 deletions

View File

@ -802,12 +802,14 @@ object. Is all this mechanism really necessary?
c++std-lib-12333: c++std-lib-12333:
N1550 requires that for a Readable Iterator a of type X, ``*a`` returns an object of type N1550 requires that for a Readable Iterator a of type X, ``*a`` returns an object of type
iterator_traits<X>::reference. ``istreambuf_iterator::operator*`` returns charT, but ``iterator_traits<X>::reference``. ``istreambuf_iterator::operator*`` returns ``charT``, but
istreambuf_iterator::reference is charT&. So am I overlooking something, or is ``istreambuf_iterator::reference`` is ``charT&``. So am I overlooking something, or is
istreambuf_iterator not Readable ``istreambuf_iterator`` not Readable.
:Proposed resolution: **Needs language** (Jeremy) :Proposed resolution:
Remove requirements on the reference type from Readable Iterator. Remove all constraints on ``iterator_traits<X>::reference`` in Readable Iterator
and Lvalue Iterator. Change Lvalue Iterator to refer to ``T&`` instead of
``iterator_traits<X>::reference``.

View File

@ -384,24 +384,12 @@ type <tt class="literal"><span class="pre">T</span></tt>.</p>
<td>Any non-reference, <td>Any non-reference,
non-cv-qualified type</td> non-cv-qualified type</td>
</tr> </tr>
<tr><td><tt class="literal"><span class="pre">iterator_traits&lt;X&gt;::reference</span></tt></td>
<td><tt class="literal"><span class="pre">R</span></tt>, Convertible to
<tt class="literal"><span class="pre">T</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="literal"><span class="pre">*a</span></tt></td> <tr><td><tt class="literal"><span class="pre">*a</span></tt></td>
<td>Convertible to <tt class="literal"><span class="pre">R</span></tt>, <td>Convertible to <tt class="literal"><span class="pre">T</span></tt></td>
Convertible to <tt class="literal"><span class="pre">T</span></tt></td>
<td>pre: <tt class="literal"><span class="pre">a</span></tt> is <td>pre: <tt class="literal"><span class="pre">a</span></tt> is
dereferenceable. If <tt class="literal"><span class="pre">a</span> dereferenceable. If <tt class="literal"><span class="pre">a</span>
<span class="pre">==</span> <span class="pre">b</span></tt> then <tt class="literal"><span class="pre">*a</span></tt> is <span class="pre">==</span> <span class="pre">b</span></tt> then <tt class="literal"><span class="pre">*a</span></tt> is
equivalent to <tt class="literal"><span class="pre">*b</span></tt></td> equivalent to <tt class="literal"><span class="pre">*b</span></tt>.</td>
</tr>
<tr><td><tt class="literal"><span class="pre">static_cast&lt;T&gt;(</span>
<span class="pre">static_cast&lt;R&gt;(*a)</span> <span class="pre">)</span></tt></td>
<td><tt class="literal"><span class="pre">T</span></tt></td>
<td>equivalent to
<tt class="literal"><span class="pre">static_cast&lt;T&gt;(*a)</span></tt></td>
</tr> </tr>
<tr><td><tt class="literal"><span class="pre">a-&gt;m</span></tt></td> <tr><td><tt class="literal"><span class="pre">a-&gt;m</span></tt></td>
<td><tt class="literal"><span class="pre">U&amp;</span></tt></td> <td><tt class="literal"><span class="pre">U&amp;</span></tt></td>
@ -411,10 +399,8 @@ to <tt class="literal"><span class="pre">(*a).m</span></tt></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<!-- TR1: the originally-proposed requirement that typeof(*a) == R <!-- We won't say anything about iterator_traits<X>::reference until
was too restrictive. Now we just require that it's the DR is resolved. -->
convertible to R and that accessing a T through that conversion
is equivalent to accessing a T directly. -->
<a class="target" id="writable-iterator" name="writable-iterator"></a></div> <a class="target" id="writable-iterator" name="writable-iterator"></a></div>
<div class="section" id="writable-iterators-lib-writable-iterators"> <div class="section" id="writable-iterators-lib-writable-iterators">
<h4><a class="toc-backref" href="#id12" name="writable-iterators-lib-writable-iterators">Writable Iterators [lib.writable.iterators]</a></h4> <h4><a class="toc-backref" href="#id12" name="writable-iterators-lib-writable-iterators">Writable Iterators [lib.writable.iterators]</a></h4>
@ -480,8 +466,9 @@ exchanged</td>
</div> </div>
<div class="section" id="lvalue-iterators-lib-lvalue-iterators"> <div class="section" id="lvalue-iterators-lib-lvalue-iterators">
<h4><a class="toc-backref" href="#id14" name="lvalue-iterators-lib-lvalue-iterators">Lvalue Iterators [lib.lvalue.iterators]</a></h4> <h4><a class="toc-backref" href="#id14" name="lvalue-iterators-lib-lvalue-iterators">Lvalue Iterators [lib.lvalue.iterators]</a></h4>
<p>The <em>Lvalue Iterator</em> concept adds the requirement that the <p>The <em>Lvalue Iterator</em> concept adds the requirement that the return
<tt class="literal"><span class="pre">reference</span></tt> type be a reference to the value type of the iterator.</p> type of <tt class="literal"><span class="pre">operator*</span></tt> type be a reference to the value type of the
iterator.</p>
<table class="table" frame="border" rules="all"> <table class="table" frame="border" rules="all">
<colgroup> <colgroup>
<col width="42%" /> <col width="42%" />
@ -493,16 +480,20 @@ exchanged</td>
</tr> </tr>
<tr><th>Expression</th> <tr><th>Expression</th>
<th>Return Type</th> <th>Return Type</th>
<th>Assertion</th> <th>Note/Assertion</th>
</tr> </tr>
</thead> </thead>
<tbody valign="top"> <tbody valign="top">
<tr><td><tt class="literal"><span class="pre">iterator_traits&lt;X&gt;::reference</span></tt></td> <tr><td><tt class="literal"><span class="pre">*a</span></tt></td>
<td><tt class="literal"><span class="pre">T&amp;</span></tt></td> <td><tt class="literal"><span class="pre">T&amp;</span></tt></td>
<td><tt class="literal"><span class="pre">T</span></tt> is <em>cv</em> <td><tt class="literal"><span class="pre">T</span></tt> is <em>cv</em>
<tt class="literal"><span class="pre">iterator_traits&lt;X&gt;::value_type</span></tt> <tt class="literal"><span class="pre">iterator_traits&lt;X&gt;::value_type</span></tt>
where <em>cv</em> is an optional where <em>cv</em> is an optional
cv-qualification</td> cv-qualification.
pre: <tt class="literal"><span class="pre">a</span></tt> is
dereferenceable. If <tt class="literal"><span class="pre">a</span>
<span class="pre">==</span> <span class="pre">b</span></tt> then <tt class="literal"><span class="pre">*a</span></tt> is
equivalent to <tt class="literal"><span class="pre">*b</span></tt>.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -889,7 +880,7 @@ LocalWords: TraversalTag typename lvalues DWA Hmm JGS mis enum -->
<hr class="footer"/> <hr class="footer"/>
<div class="footer"> <div class="footer">
<a class="reference" href="new-iter-concepts.rst">View document source</a>. <a class="reference" href="new-iter-concepts.rst">View document source</a>.
Generated on: 2004-01-12 18:37 UTC. Generated on: 2004-01-12 19:53 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. 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> </div>
</body> </body>

View File

@ -368,26 +368,18 @@ type ``T``.
|``iterator_traits<X>::value_type`` |``T`` |Any non-reference, | |``iterator_traits<X>::value_type`` |``T`` |Any non-reference, |
| | |non-cv-qualified type | | | |non-cv-qualified type |
+-----------------------------------+------------------------+-------------------------+ +-----------------------------------+------------------------+-------------------------+
|``iterator_traits<X>::reference`` |``R``, Convertible to | | |``*a`` | Convertible to ``T`` |pre: ``a`` is |
| |``T`` | | | | |dereferenceable. If ``a |
+-----------------------------------+------------------------+-------------------------+
|``*a`` |Convertible to ``R``, |pre: ``a`` is |
| |Convertible to ``T`` |dereferenceable. If ``a |
| | |== b`` then ``*a`` is | | | |== b`` then ``*a`` is |
| | |equivalent to ``*b`` | | | |equivalent to ``*b``. |
+-----------------------------------+------------------------+-------------------------+
|``static_cast<T>( |``T`` |equivalent to |
|static_cast<R>(*a) )`` | |``static_cast<T>(*a)`` |
+-----------------------------------+------------------------+-------------------------+ +-----------------------------------+------------------------+-------------------------+
|``a->m`` |``U&`` |pre: ``(*a).m`` is | |``a->m`` |``U&`` |pre: ``(*a).m`` is |
| | |well-defined. Equivalent| | | |well-defined. Equivalent|
| | |to ``(*a).m`` | | | |to ``(*a).m`` |
+-----------------------------------+------------------------+-------------------------+ +-----------------------------------+------------------------+-------------------------+
.. TR1: the originally-proposed requirement that typeof(*a) == R .. We won't say anything about iterator_traits<X>::reference until
was too restrictive. Now we just require that it's the DR is resolved.
convertible to R and that accessing a T through that conversion
is equivalent to accessing a T directly.
.. _Writable Iterator: .. _Writable Iterator:
@ -432,21 +424,27 @@ expressions are valid and respect the stated semantics.
Lvalue Iterators [lib.lvalue.iterators] Lvalue Iterators [lib.lvalue.iterators]
--------------------------------------- ---------------------------------------
The *Lvalue Iterator* concept adds the requirement that the The *Lvalue Iterator* concept adds the requirement that the return
``reference`` type be a reference to the value type of the iterator. type of ``operator*`` type be a reference to the value type of the
iterator.
+---------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------+
| Lvalue Iterator Requirements | | Lvalue Iterator Requirements |
+---------------------------------+-----------+-----------------------------------+ +---------------------------------+-----------+-----------------------------------+
|Expression |Return Type|Assertion | |Expression |Return Type|Note/Assertion |
+=================================+===========+===================================+ +=================================+===========+===================================+
|``iterator_traits<X>::reference``|``T&`` |``T`` is *cv* | |``*a`` | ``T&`` |``T`` is *cv* |
| | |``iterator_traits<X>::value_type`` | | | |``iterator_traits<X>::value_type`` |
| | |where *cv* is an optional | | | |where *cv* is an optional |
| | |cv-qualification | | | |cv-qualification. |
| | |pre: ``a`` is |
| | |dereferenceable. If ``a |
| | |== b`` then ``*a`` is |
| | |equivalent to ``*b``. |
+---------------------------------+-----------+-----------------------------------+ +---------------------------------+-----------+-----------------------------------+
Iterator Traversal Concepts [lib.iterator.traversal] Iterator Traversal Concepts [lib.iterator.traversal]
++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++