mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-24 01:47:17 +02:00
updated to match .rst
[SVN r21059]
This commit is contained in:
@ -3,204 +3,13 @@
|
||||
<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/" />
|
||||
<meta name="generator" content="Docutils 0.2.8: http://docutils.sourceforge.net/" />
|
||||
<title>New Iterator Concepts</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="2003-11-22" />
|
||||
<meta name="date" content="2003-12-01" />
|
||||
<meta name="copyright" content="Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved" />
|
||||
<style type="text/css"><!--
|
||||
|
||||
/*
|
||||
:Author: David Goodger
|
||||
:Contact: goodger@users.sourceforge.net
|
||||
:date: $Date$
|
||||
:version: $Revision$
|
||||
:copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
*/
|
||||
|
||||
.first {
|
||||
margin-top: 0 }
|
||||
|
||||
.last {
|
||||
margin-bottom: 0 }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.attention, div.caution, div.danger, div.error, div.hint,
|
||||
div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.hint p.admonition-title, div.important p.admonition-title,
|
||||
div.note p.admonition-title, div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
font-size: smaller }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr {
|
||||
width: 75% }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font-family: serif ;
|
||||
font-size: 100% }
|
||||
|
||||
pre.line-block {
|
||||
font-family: serif ;
|
||||
font-size: 100% }
|
||||
|
||||
pre.literal-block, pre.doctest-block {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em ;
|
||||
background-color: #eeeeee }
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option-argument {
|
||||
font-style: italic }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
table {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.citation {
|
||||
border-left: solid thin gray ;
|
||||
padding-left: 0.5ex }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid thin black ;
|
||||
padding-left: 0.5ex }
|
||||
|
||||
td, th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
th.docinfo-name, th.field-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap }
|
||||
|
||||
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
|
||||
font-size: 100% }
|
||||
|
||||
tt {
|
||||
background-color: #eeeeee }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
--></style>
|
||||
<link rel="stylesheet" href="default.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="new-iterator-concepts">
|
||||
@ -218,7 +27,7 @@ ul.auto-toc {
|
||||
Systems 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>2003-11-22</td></tr>
|
||||
<td>2003-12-01</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/n1550.html">n1550</a>=03-0133, which was
|
||||
accepted for Technical Report 1 by the C++ standard
|
||||
committee's library working group. This proposal is a
|
||||
@ -248,40 +57,39 @@ of iterators that are used in practice.</td>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#motivation" id="id1" name="id1">Motivation</a></li>
|
||||
<li><a class="reference" href="#impact-on-the-standard" id="id2" name="id2">Impact on the Standard</a><ul>
|
||||
<li><a class="reference" href="#proposed-changes-for-tr1" id="id3" name="id3">Proposed Changes for TR1</a></li>
|
||||
<li><a class="reference" href="#possible-but-not-proposed-changes-to-the-working-paper" id="id4" name="id4">Possible (but not proposed) Changes to the Working Paper</a><ul>
|
||||
<li><a class="reference" href="#changes-to-algorithm-requirements" id="id5" name="id5">Changes to Algorithm Requirements</a></li>
|
||||
<li><a class="reference" href="#deprecations" id="id6" name="id6">Deprecations</a></li>
|
||||
<li><a class="reference" href="#vector-bool" id="id7" name="id7"><tt class="literal"><span class="pre">vector<bool></span></tt></a></li>
|
||||
<li><a class="reference" href="#possible-but-not-proposed-changes-to-the-working-paper" id="id3" name="id3">Possible (but not proposed) Changes to the Working Paper</a><ul>
|
||||
<li><a class="reference" href="#changes-to-algorithm-requirements" id="id4" name="id4">Changes to Algorithm Requirements</a></li>
|
||||
<li><a class="reference" href="#deprecations" id="id5" name="id5">Deprecations</a></li>
|
||||
<li><a class="reference" href="#vector-bool" id="id6" name="id6"><tt class="literal"><span class="pre">vector<bool></span></tt></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#design" id="id8" name="id8">Design</a></li>
|
||||
<li><a class="reference" href="#proposed-text" id="id9" name="id9">Proposed Text</a><ul>
|
||||
<li><a class="reference" href="#addition-to-lib-iterator-requirements" id="id10" name="id10">Addition to [lib.iterator.requirements]</a><ul>
|
||||
<li><a class="reference" href="#iterator-value-access-concepts-lib-iterator-value-access" id="id11" name="id11">Iterator Value Access Concepts [lib.iterator.value.access]</a><ul>
|
||||
<li><a class="reference" href="#readable-iterators-lib-readable-iterators" id="id12" name="id12">Readable Iterators [lib.readable.iterators]</a></li>
|
||||
<li><a class="reference" href="#writable-iterators-lib-writable-iterators" id="id13" name="id13">Writable Iterators [lib.writable.iterators]</a></li>
|
||||
<li><a class="reference" href="#swappable-iterators-lib-swappable-iterators" id="id14" name="id14">Swappable Iterators [lib.swappable.iterators]</a></li>
|
||||
<li><a class="reference" href="#lvalue-iterators-lib-lvalue-iterators" id="id15" name="id15">Lvalue Iterators [lib.lvalue.iterators]</a></li>
|
||||
<li><a class="reference" href="#design" id="id7" name="id7">Design</a></li>
|
||||
<li><a class="reference" href="#proposed-text" id="id8" name="id8">Proposed Text</a><ul>
|
||||
<li><a class="reference" href="#addition-to-lib-iterator-requirements" id="id9" name="id9">Addition to [lib.iterator.requirements]</a><ul>
|
||||
<li><a class="reference" href="#iterator-value-access-concepts-lib-iterator-value-access" id="id10" name="id10">Iterator Value Access Concepts [lib.iterator.value.access]</a><ul>
|
||||
<li><a class="reference" href="#readable-iterators-lib-readable-iterators" id="id11" name="id11">Readable Iterators [lib.readable.iterators]</a></li>
|
||||
<li><a class="reference" href="#writable-iterators-lib-writable-iterators" id="id12" name="id12">Writable Iterators [lib.writable.iterators]</a></li>
|
||||
<li><a class="reference" href="#swappable-iterators-lib-swappable-iterators" id="id13" name="id13">Swappable Iterators [lib.swappable.iterators]</a></li>
|
||||
<li><a class="reference" href="#lvalue-iterators-lib-lvalue-iterators" id="id14" name="id14">Lvalue Iterators [lib.lvalue.iterators]</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#iterator-traversal-concepts-lib-iterator-traversal" id="id16" name="id16">Iterator Traversal Concepts [lib.iterator.traversal]</a><ul>
|
||||
<li><a class="reference" href="#incrementable-iterators-lib-incrementable-iterators" id="id17" name="id17">Incrementable Iterators [lib.incrementable.iterators]</a></li>
|
||||
<li><a class="reference" href="#single-pass-iterators-lib-single-pass-iterators" id="id18" name="id18">Single Pass Iterators [lib.single.pass.iterators]</a></li>
|
||||
<li><a class="reference" href="#forward-traversal-iterators-lib-forward-traversal-iterators" id="id19" name="id19">Forward Traversal Iterators [lib.forward.traversal.iterators]</a></li>
|
||||
<li><a class="reference" href="#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators" id="id20" name="id20">Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators]</a></li>
|
||||
<li><a class="reference" href="#random-access-traversal-iterators-lib-random-access-traversal-iterators" id="id21" name="id21">Random Access Traversal Iterators [lib.random.access.traversal.iterators]</a></li>
|
||||
<li><a class="reference" href="#iterator-traversal-concepts-lib-iterator-traversal" id="id15" name="id15">Iterator Traversal Concepts [lib.iterator.traversal]</a><ul>
|
||||
<li><a class="reference" href="#incrementable-iterators-lib-incrementable-iterators" id="id16" name="id16">Incrementable Iterators [lib.incrementable.iterators]</a></li>
|
||||
<li><a class="reference" href="#single-pass-iterators-lib-single-pass-iterators" id="id17" name="id17">Single Pass Iterators [lib.single.pass.iterators]</a></li>
|
||||
<li><a class="reference" href="#forward-traversal-iterators-lib-forward-traversal-iterators" id="id18" name="id18">Forward Traversal Iterators [lib.forward.traversal.iterators]</a></li>
|
||||
<li><a class="reference" href="#bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators" id="id19" name="id19">Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators]</a></li>
|
||||
<li><a class="reference" href="#random-access-traversal-iterators-lib-random-access-traversal-iterators" id="id20" name="id20">Random Access Traversal Iterators [lib.random.access.traversal.iterators]</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#addition-to-lib-iterator-synopsis" id="id22" name="id22">Addition to [lib.iterator.synopsis]</a></li>
|
||||
<li><a class="reference" href="#addition-to-lib-iterator-traits" id="id23" name="id23">Addition to [lib.iterator.traits]</a></li>
|
||||
<li><a class="reference" href="#addition-to-lib-iterator-synopsis" id="id21" name="id21">Addition to [lib.iterator.synopsis]</a></li>
|
||||
<li><a class="reference" href="#addition-to-lib-iterator-traits" id="id22" name="id22">Addition to [lib.iterator.traits]</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#footnotes" id="id24" name="id24">Footnotes</a></li>
|
||||
<li><a class="reference" href="#footnotes" id="id23" name="id23">Footnotes</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="motivation">
|
||||
@ -299,7 +107,7 @@ geared towards iterator traversal (hence the category names), while
|
||||
requirements that address value access sneak in at various places. The
|
||||
following table gives a summary of the current value access
|
||||
requirements in the iterator categories.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="31%" />
|
||||
<col width="69%" />
|
||||
@ -367,14 +175,13 @@ traversal from the need for a true reference return type.</li>
|
||||
</div>
|
||||
<div class="section" id="impact-on-the-standard">
|
||||
<h1><a class="toc-backref" href="#id2" name="impact-on-the-standard">Impact on the Standard</a></h1>
|
||||
<div class="section" id="proposed-changes-for-tr1">
|
||||
<h2><a class="toc-backref" href="#id3" name="proposed-changes-for-tr1">Proposed Changes for TR1</a></h2>
|
||||
<p>The new iterator concepts are backward-compatible with the old
|
||||
iterator requirements, and old iterators are forward-compatible with
|
||||
the new iterator concepts. That is to say, iterators that satisfy the
|
||||
old requirements also satisfy appropriate concepts in the new system,
|
||||
and iterators modeling the new concepts will automatically satisfy the
|
||||
appropriate old requirements.</p>
|
||||
<p>This proposal for TR1 is a pure extension. Further, the new iterator
|
||||
concepts are backward-compatible with the old iterator requirements,
|
||||
and old iterators are forward-compatible with the new iterator
|
||||
concepts. That is to say, iterators that satisfy the old requirements
|
||||
also satisfy appropriate concepts in the new system, and iterators
|
||||
modeling the new concepts will automatically satisfy the appropriate
|
||||
old requirements.</p>
|
||||
<!-- I think we need to say something about the resolution to allow
|
||||
convertibility to any of the old-style tags as a TR issue (hope it
|
||||
made it). -DWA -->
|
||||
@ -382,23 +189,22 @@ made it). -DWA -->
|
||||
standards conforming input iterator is allowed to have
|
||||
a tag that is not input_iterator_tag but that
|
||||
is convertible to input_iterator_tag? -JGS -->
|
||||
<p>The algorithms in the standard library benefit from the new iterator
|
||||
concepts because the new concepts provide a more accurate way to
|
||||
express their type requirements. The result is algorithms that are
|
||||
usable in more situations and have fewer type requirements.</p>
|
||||
<p>Note that as currently specified, <tt class="literal"><span class="pre">istreambuf_iterator</span></tt> doesn't
|
||||
meet the Readable Iterator requirements because its <tt class="literal"><span class="pre">value_type</span></tt>
|
||||
is not convertible to its <tt class="literal"><span class="pre">reference</span></tt> type. We believe this to
|
||||
be a defect in the standard; it should be fixed by changing its
|
||||
<tt class="literal"><span class="pre">reference</span></tt> type from <tt class="literal"><span class="pre">value_type&</span></tt> to <tt class="literal"><span class="pre">value_type</span> <span class="pre">const&</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section" id="possible-but-not-proposed-changes-to-the-working-paper">
|
||||
<h2><a class="toc-backref" href="#id4" name="possible-but-not-proposed-changes-to-the-working-paper">Possible (but not proposed) Changes to the Working Paper</a></h2>
|
||||
<h2><a class="toc-backref" href="#id3" name="possible-but-not-proposed-changes-to-the-working-paper">Possible (but not proposed) Changes to the Working Paper</a></h2>
|
||||
<p>The extensions in this paper suggest several changes we might make
|
||||
to the working paper for the next standard. These changes are not
|
||||
a formal part of this proposal for TR1.</p>
|
||||
<div class="section" id="changes-to-algorithm-requirements">
|
||||
<h3><a class="toc-backref" href="#id5" name="changes-to-algorithm-requirements">Changes to Algorithm Requirements</a></h3>
|
||||
<h3><a class="toc-backref" href="#id4" name="changes-to-algorithm-requirements">Changes to Algorithm Requirements</a></h3>
|
||||
<p>The algorithms in the standard library could benefit from the new
|
||||
iterator concepts because the new concepts provide a more accurate way
|
||||
to express their type requirements. The result is algorithms that are
|
||||
usable in more situations and have fewer type requirements.</p>
|
||||
<p>For the next working paper (but not for TR1), the committee should
|
||||
consider the following changes to the type requirements of
|
||||
algorithms. These changes are phrased as phrased as textual
|
||||
@ -460,14 +266,14 @@ Bidirectional Iterator (2) -> Bidirectional Traversal Iterator and Writable I
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="deprecations">
|
||||
<h3><a class="toc-backref" href="#id6" name="deprecations">Deprecations</a></h3>
|
||||
<h3><a class="toc-backref" href="#id5" name="deprecations">Deprecations</a></h3>
|
||||
<p>For the next working paper (but not for TR1), the committee should
|
||||
consider deprecating the old iterator tags, and
|
||||
std::iterator_traits, since it will be superceded by individual
|
||||
traits metafunctions.</p>
|
||||
</div>
|
||||
<div class="section" id="vector-bool">
|
||||
<h3><a class="toc-backref" href="#id7" name="vector-bool"><tt class="literal"><span class="pre">vector<bool></span></tt></a></h3>
|
||||
<h3><a class="toc-backref" href="#id6" name="vector-bool"><tt class="literal"><span class="pre">vector<bool></span></tt></a></h3>
|
||||
<p>For the next working paper (but not for TR1), the committee should
|
||||
consider reclassifying <tt class="literal"><span class="pre">vector<bool>::iterator</span></tt> as a Random
|
||||
Access Traversal Iterator and Readable Iterator and Writable
|
||||
@ -476,7 +282,7 @@ Iterator.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="design">
|
||||
<h1><a class="toc-backref" href="#id8" name="design">Design</a></h1>
|
||||
<h1><a class="toc-backref" href="#id7" name="design">Design</a></h1>
|
||||
<p>The iterator requirements are to be separated into two groups. One set
|
||||
of concepts handles the syntax and semantics of value access:</p>
|
||||
<ul class="simple">
|
||||
@ -511,64 +317,19 @@ given in the following diagram.</p>
|
||||
<p>Like the old iterator requirements, we provide tags for purposes of
|
||||
dispatching based on the traversal concepts. The tags are related via
|
||||
inheritance so that a tag is convertible to another tag if the concept
|
||||
associated with the first tag is a refinement of the second tag.
|
||||
Since the access concepts are not related via refinement, but instead
|
||||
cover orthogonal issues, we do not use tags for the access concepts,
|
||||
but instead use the equivalent of a bit field.</p>
|
||||
<p>We provide an access mechanism for mapping iterator types to the new
|
||||
traversal tags and access bit field. Our design reuses
|
||||
<tt class="literal"><span class="pre">iterator_traits<Iter>::iterator_category</span></tt> as the access
|
||||
mechanism. To that end, the access and traversal information is
|
||||
bundled into a single type using the following <cite>iterator_tag</cite> class.</p>
|
||||
<pre class="literal-block">
|
||||
enum iterator_access { readable_iterator = 1, writable_iterator = 2,
|
||||
swappable_iterator = 4, lvalue_iterator = 8 };
|
||||
|
||||
template <unsigned int access_bits, class TraversalTag>
|
||||
struct iterator_tag : /* appropriate old category or categories */ {
|
||||
static const iterator_access access =
|
||||
(iterator_access)access_bits &
|
||||
(readable_iterator | writable_iterator | swappable_iterator);
|
||||
typedef TraversalTag traversal;
|
||||
};
|
||||
</pre>
|
||||
<p>The <tt class="literal"><span class="pre">access_bits</span></tt> argument is declared to be <tt class="literal"><span class="pre">unsigned</span> <span class="pre">int</span></tt>
|
||||
instead of the enum <tt class="literal"><span class="pre">iterator_access</span></tt> for convenience of use. For
|
||||
example, the expression <tt class="literal"><span class="pre">(readable_iterator</span> <span class="pre">|</span> <span class="pre">writable_iterator)</span></tt>
|
||||
produces an unsigned int, not an <tt class="literal"><span class="pre">iterator_access</span></tt>. The purpose of
|
||||
the <tt class="literal"><span class="pre">lvalue_iterator</span></tt> part of the <tt class="literal"><span class="pre">iterator_access</span></tt> enum is to
|
||||
communicate to <tt class="literal"><span class="pre">iterator_tag</span></tt> whether the reference type is an
|
||||
lvalue so that the appropriate old category can be chosen for the base
|
||||
class. The <tt class="literal"><span class="pre">lvalue_iterator</span></tt> bit is not recorded in the
|
||||
<tt class="literal"><span class="pre">iterator_tag::access</span></tt> data member.</p>
|
||||
<p>The <tt class="literal"><span class="pre">iterator_tag</span></tt> class template is derived from the appropriate
|
||||
iterator tag or tags from the old requirements based on the access
|
||||
bits and traversal tag passed as template parameters. The algorithm
|
||||
for determining the old tag or tags picks the least-refined old
|
||||
concepts that include all of the requirements of the access and
|
||||
traversal concepts (that is, the closest fit), if any such category
|
||||
exists. For example, the category tag for a Readable Single Pass
|
||||
Iterator will always be derived from <tt class="literal"><span class="pre">input_iterator_tag</span></tt>, while the
|
||||
category tag for a Single Pass Iterator that is both Readable and
|
||||
Writable will be derived from both <tt class="literal"><span class="pre">input_iterator_tag</span></tt> and
|
||||
<tt class="literal"><span class="pre">output_iterator_tag</span></tt>.</p>
|
||||
<p>We also provide several helper classes that make it convenient to
|
||||
obtain the access and traversal characteristics of an iterator. These
|
||||
helper classes work both for iterators whose <tt class="literal"><span class="pre">iterator_category</span></tt> is
|
||||
<tt class="literal"><span class="pre">iterator_tag</span></tt> and also for iterators using the original iterator
|
||||
categories.</p>
|
||||
<pre class="literal-block">
|
||||
template <class Iterator> struct is_readable { typedef ... type; };
|
||||
template <class Iterator> struct is_writable { typedef ... type; };
|
||||
template <class Iterator> struct is_swappable { typedef ... type; };
|
||||
template <class Iterator> struct traversal_category { typedef ... type; };
|
||||
</pre>
|
||||
<p>We do not include a helper class <tt class="literal"><span class="pre">is_lvalue_iterator</span></tt> because that
|
||||
can easily be deduced by checking whether
|
||||
<tt class="literal"><span class="pre">iterator_traits<Iterator>::reference</span></tt> is a real reference.</p>
|
||||
<p>The most difficult design decision concerned the <tt class="literal"><span class="pre">operator[]</span></tt>. The
|
||||
direct approach for specifying <tt class="literal"><span class="pre">operator[]</span></tt> would have a return type
|
||||
of <tt class="literal"><span class="pre">reference</span></tt>; the same as <tt class="literal"><span class="pre">operator*</span></tt>. However, going in this
|
||||
associated with the first tag is a refinement of the second tag. Our
|
||||
design reuses <tt class="literal"><span class="pre">iterator_traits<Iter>::iterator_category</span></tt> as the
|
||||
access mechanism for the traversal tag. If an iterator wishes to meet
|
||||
the requirements of both a new iterator concept and an old iterator
|
||||
concept, it can use an iterator category type that inherits from both
|
||||
the the old iterator tag and the new traversal tag.</p>
|
||||
<p>We do not provide tags for the purposes of dispatching based on the
|
||||
access concepts. There are two reasons: we could not find a way to
|
||||
automatically infer the right access tags for old-style iterators and
|
||||
the need for dispatching based on the access concepts is not as great.</p>
|
||||
<p>A difficult design decision concerned the <tt class="literal"><span class="pre">operator[]</span></tt>. The direct
|
||||
approach for specifying <tt class="literal"><span class="pre">operator[]</span></tt> would have a return type of
|
||||
<tt class="literal"><span class="pre">reference</span></tt>; the same as <tt class="literal"><span class="pre">operator*</span></tt>. However, going in this
|
||||
direction would mean that an iterator satisfying the old Random Access
|
||||
Iterator requirements would not necessarily be a model of Readable or
|
||||
Writable Lvalue Iterator. Instead we have chosen a design that
|
||||
@ -578,23 +339,23 @@ only required to return something convertible to the <tt class="literal"><span c
|
||||
<tt class="literal"><span class="pre">i[n]</span> <span class="pre">=</span> <span class="pre">t</span></tt> (for a Writable Iterator).</p>
|
||||
</div>
|
||||
<div class="section" id="proposed-text">
|
||||
<h1><a class="toc-backref" href="#id9" name="proposed-text">Proposed Text</a></h1>
|
||||
<h1><a class="toc-backref" href="#id8" name="proposed-text">Proposed Text</a></h1>
|
||||
<div class="section" id="addition-to-lib-iterator-requirements">
|
||||
<h2><a class="toc-backref" href="#id10" name="addition-to-lib-iterator-requirements">Addition to [lib.iterator.requirements]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id9" name="addition-to-lib-iterator-requirements">Addition to [lib.iterator.requirements]</a></h2>
|
||||
<div class="section" id="iterator-value-access-concepts-lib-iterator-value-access">
|
||||
<h3><a class="toc-backref" href="#id11" name="iterator-value-access-concepts-lib-iterator-value-access">Iterator Value Access Concepts [lib.iterator.value.access]</a></h3>
|
||||
<h3><a class="toc-backref" href="#id10" name="iterator-value-access-concepts-lib-iterator-value-access">Iterator Value Access Concepts [lib.iterator.value.access]</a></h3>
|
||||
<p>In the tables below, <tt class="literal"><span class="pre">X</span></tt> is an iterator type, <tt class="literal"><span class="pre">a</span></tt> is a constant
|
||||
object of type <tt class="literal"><span class="pre">X</span></tt>, <tt class="literal"><span class="pre">R</span></tt> is
|
||||
<tt class="literal"><span class="pre">std::iterator_traits<X>::reference</span></tt>, <tt class="literal"><span class="pre">T</span></tt> is
|
||||
<tt class="literal"><span class="pre">std::iterator_traits<X>::value_type</span></tt>, and <tt class="literal"><span class="pre">v</span></tt> is a constant
|
||||
object of type <tt class="literal"><span class="pre">T</span></tt>.</p>
|
||||
<a class="target" id="readable-iterator" name="readable-iterator"></a><div class="section" id="readable-iterators-lib-readable-iterators">
|
||||
<h4><a class="toc-backref" href="#id12" name="readable-iterators-lib-readable-iterators">Readable Iterators [lib.readable.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id11" name="readable-iterators-lib-readable-iterators">Readable Iterators [lib.readable.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Readable Iterator</em> concept
|
||||
for the value type <tt class="literal"><span class="pre">T</span></tt> if the following expressions are valid and
|
||||
respect the stated semantics. <tt class="literal"><span class="pre">U</span></tt> is the type of any specified
|
||||
member of type <tt class="literal"><span class="pre">T</span></tt>.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="42%" />
|
||||
<col width="29%" />
|
||||
@ -643,13 +404,13 @@ to <tt class="literal"><span class="pre">(*a).m</span></tt></td>
|
||||
</table>
|
||||
<a class="target" id="writable-iterator" name="writable-iterator"></a></div>
|
||||
<div class="section" id="writable-iterators-lib-writable-iterators">
|
||||
<h4><a class="toc-backref" href="#id13" 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>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Writable Iterator</em> concept
|
||||
if the following expressions are valid and respect the stated
|
||||
semantics. In addition, a model of <em>Writable Iterator</em> must include
|
||||
in its documentation the <em>set of value types</em> that it allows for
|
||||
output.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="37%" />
|
||||
<col width="21%" />
|
||||
@ -674,11 +435,11 @@ value types of <tt class="literal"><span class="pre">X</span></tt></td>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="swappable-iterators-lib-swappable-iterators">
|
||||
<h4><a class="toc-backref" href="#id14" name="swappable-iterators-lib-swappable-iterators">Swappable Iterators [lib.swappable.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id13" name="swappable-iterators-lib-swappable-iterators">Swappable Iterators [lib.swappable.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Swappable Iterator</em> concept
|
||||
if the following expressions are valid and respect the stated
|
||||
semantics.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="37%" />
|
||||
<col width="19%" />
|
||||
@ -706,10 +467,10 @@ exchanged</td>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="lvalue-iterators-lib-lvalue-iterators">
|
||||
<h4><a class="toc-backref" href="#id15" 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
|
||||
<tt class="literal"><span class="pre">reference</span></tt> type be a reference to the value type of the iterator.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="42%" />
|
||||
<col width="14%" />
|
||||
@ -736,17 +497,17 @@ cv-qualification</td>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="iterator-traversal-concepts-lib-iterator-traversal">
|
||||
<h3><a class="toc-backref" href="#id16" name="iterator-traversal-concepts-lib-iterator-traversal">Iterator Traversal Concepts [lib.iterator.traversal]</a></h3>
|
||||
<h3><a class="toc-backref" href="#id15" name="iterator-traversal-concepts-lib-iterator-traversal">Iterator Traversal Concepts [lib.iterator.traversal]</a></h3>
|
||||
<p>In the tables below, <tt class="literal"><span class="pre">X</span></tt> is an iterator type, <tt class="literal"><span class="pre">a</span></tt> and <tt class="literal"><span class="pre">b</span></tt> are
|
||||
constant objects of type <tt class="literal"><span class="pre">X</span></tt>, <tt class="literal"><span class="pre">r</span></tt> and <tt class="literal"><span class="pre">s</span></tt> are mutable objects of
|
||||
type <tt class="literal"><span class="pre">X</span></tt>, <tt class="literal"><span class="pre">T</span></tt> is <tt class="literal"><span class="pre">std::iterator_traits<X>::value_type</span></tt>, and
|
||||
<tt class="literal"><span class="pre">v</span></tt> is a constant object of type <tt class="literal"><span class="pre">T</span></tt>.</p>
|
||||
<div class="section" id="incrementable-iterators-lib-incrementable-iterators">
|
||||
<h4><a class="toc-backref" href="#id17" name="incrementable-iterators-lib-incrementable-iterators">Incrementable Iterators [lib.incrementable.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id16" name="incrementable-iterators-lib-incrementable-iterators">Incrementable Iterators [lib.incrementable.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Incrementable Iterator</em>
|
||||
concept if the following expressions are valid and respect the stated
|
||||
semantics.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="39%" />
|
||||
<col width="37%" />
|
||||
@ -785,11 +546,11 @@ semantics.</p>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="single-pass-iterators-lib-single-pass-iterators">
|
||||
<h4><a class="toc-backref" href="#id18" name="single-pass-iterators-lib-single-pass-iterators">Single Pass Iterators [lib.single.pass.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id17" name="single-pass-iterators-lib-single-pass-iterators">Single Pass Iterators [lib.single.pass.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Single Pass Iterator</em>
|
||||
concept if the following expressions are valid and respect the stated
|
||||
semantics.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="36%" />
|
||||
<col width="33%" />
|
||||
@ -831,11 +592,11 @@ relation over its domain</td>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="forward-traversal-iterators-lib-forward-traversal-iterators">
|
||||
<h4><a class="toc-backref" href="#id19" name="forward-traversal-iterators-lib-forward-traversal-iterators">Forward Traversal Iterators [lib.forward.traversal.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id18" name="forward-traversal-iterators-lib-forward-traversal-iterators">Forward Traversal Iterators [lib.forward.traversal.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Forward Traversal Iterator</em>
|
||||
concept if the following expressions are valid and respect the stated
|
||||
semantics.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="44%" />
|
||||
<col width="39%" />
|
||||
@ -878,11 +639,11 @@ the distance between iterators</td>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators">
|
||||
<h4><a class="toc-backref" href="#id20" name="bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id19" name="bidirectional-traversal-iterators-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterators [lib.bidirectional.traversal.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Bidirectional Traversal
|
||||
Iterator</em> concept if the following expressions are valid and respect
|
||||
the stated semantics.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="35%" />
|
||||
<col width="44%" />
|
||||
@ -930,13 +691,13 @@ implies <tt class="literal"><span class="pre">r</span> <span class="pre">==</spa
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="random-access-traversal-iterators-lib-random-access-traversal-iterators">
|
||||
<h4><a class="toc-backref" href="#id21" name="random-access-traversal-iterators-lib-random-access-traversal-iterators">Random Access Traversal Iterators [lib.random.access.traversal.iterators]</a></h4>
|
||||
<h4><a class="toc-backref" href="#id20" name="random-access-traversal-iterators-lib-random-access-traversal-iterators">Random Access Traversal Iterators [lib.random.access.traversal.iterators]</a></h4>
|
||||
<p>A class or built-in type <tt class="literal"><span class="pre">X</span></tt> models the <em>Random Access Traversal
|
||||
Iterator</em> concept if the following expressions are valid and respect
|
||||
the stated semantics. In the table below, <tt class="literal"><span class="pre">Distance</span></tt> is
|
||||
<tt class="literal"><span class="pre">iterator_traits<X>::difference_type</span></tt> and <tt class="literal"><span class="pre">n</span></tt> represents a
|
||||
constant object of type <tt class="literal"><span class="pre">Distance</span></tt>.</p>
|
||||
<table border class="table">
|
||||
<table class="table" frame="border" rules="all">
|
||||
<colgroup>
|
||||
<col width="31%" />
|
||||
<col width="35%" />
|
||||
@ -1044,7 +805,7 @@ ordering relation</td>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="addition-to-lib-iterator-synopsis">
|
||||
<h2><a class="toc-backref" href="#id22" name="addition-to-lib-iterator-synopsis">Addition to [lib.iterator.synopsis]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id21" name="addition-to-lib-iterator-synopsis">Addition to [lib.iterator.synopsis]</a></h2>
|
||||
<pre class="literal-block">
|
||||
// lib.iterator.traits, traits and tags
|
||||
template <class Iterator> struct is_readable_iterator;
|
||||
@ -1058,7 +819,7 @@ struct random_access_traversal_tag : bidirectional_traversal_tag { };
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="addition-to-lib-iterator-traits">
|
||||
<h2><a class="toc-backref" href="#id23" name="addition-to-lib-iterator-traits">Addition to [lib.iterator.traits]</a></h2>
|
||||
<h2><a class="toc-backref" href="#id22" name="addition-to-lib-iterator-traits">Addition to [lib.iterator.traits]</a></h2>
|
||||
<p>The <tt class="literal"><span class="pre">is_readable_iterator</span></tt> and <tt class="literal"><span class="pre">iterator_traversal</span></tt> class
|
||||
templates satisfy the <a class="reference" href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1519.htm">UnaryTypeTrait</a> requirements.</p>
|
||||
<p>Given an iterator type <tt class="literal"><span class="pre">X</span></tt>, <tt class="literal"><span class="pre">is_readable_iterator<X>::value</span></tt>
|
||||
@ -1087,7 +848,7 @@ traversal-category(X) =
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="footnotes">
|
||||
<h1><a class="toc-backref" href="#id24" name="footnotes">Footnotes</a></h1>
|
||||
<h1><a class="toc-backref" href="#id23" 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>
|
||||
@ -1100,11 +861,5 @@ LocalWords: incrementable xxx min prev inplace png oldeqnew AccessTag struct
|
||||
LocalWords: TraversalTag typename lvalues DWA Hmm JGS mis enum -->
|
||||
</div>
|
||||
</div>
|
||||
<hr class="footer" />
|
||||
<div class="footer">
|
||||
<a class="reference" href="new-iter-concepts.rst">View document source</a>.
|
||||
Generated on: 2003-11-24 04:21 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>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user