Separate access and traversal for iterator_adaptor

[SVN r20162]
This commit is contained in:
Dave Abrahams 2003-09-22 19:55:01 +00:00
parent 50fe1b062b
commit ebb09db44e
12 changed files with 485 additions and 170 deletions

View File

@ -1,12 +1,18 @@
::
template <class Incrementable, class Category = use_default, class Difference = use_default>
template <
class Incrementable
, unsigned Access = use_default_access
, class Traversal = use_default
, class Difference = use_default
>
class counting_iterator
: public iterator_adaptor<
counting_iterator<Incrementable, Category, Difference>
counting_iterator<Incrementable, Access, Traversal, Difference>
, Incrementable
, Incrementable
, /* see details for category */
, Access
, /* see details for traversal category */
, Incrementable const&
, Incrementable const*
, /* distance = Difference or a signed integral type */>

View File

@ -219,7 +219,7 @@ Lab</a>, University of Hanover <a class="last reference" href="http://www.ive.un
Railway Operation and Construction</a></td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>2003-09-22</td></tr>
<tr class="field"><th class="docinfo-name">Number:</th><td class="field-body"><strong>This document is a revised version of the official</strong> N1476=03-0059</td>
<tr class="field"><th class="docinfo-name">Number:</th><td class="field-body">N1530=03-0113</td>
</tr>
<tr><th class="docinfo-name">Copyright:</th>
<td>Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved</td></tr>
@ -642,17 +642,18 @@ above. The <tt class="literal"><span class="pre">Base</span></tt> type need not
iterator. It need only support the operations used by the core
interface functions of <tt class="literal"><span class="pre">iterator_adaptor</span></tt> that have not been
redefined in the user's derived class.</p>
<p>Several of the template parameters of <tt class="literal"><span class="pre">iterator_adaptor</span></tt> default to
<tt class="literal"><span class="pre">use_default</span></tt>. This allows the user to make use of a default
parameter even when the user wants to specify a parameter later in the
parameter list. Also, the defaults for the corresponding associated
types are fairly complicated, so metaprogramming is required to
compute them, and <tt class="literal"><span class="pre">use_default</span></tt> can help to simplify the
implementation. Finally, <tt class="literal"><span class="pre">use_default</span></tt> is not left unspecified
<p>Several of the template parameters of <tt class="literal"><span class="pre">iterator_adaptor</span></tt> default
to <tt class="literal"><span class="pre">use_default</span></tt> (or <tt class="literal"><span class="pre">use_default_access</span></tt>). This allows the
user to make use of a default parameter even when she wants to
specify a parameter later in the parameter list. Also, the
defaults for the corresponding associated types are somewhat
complicated, so metaprogramming is required to compute them, and
<tt class="literal"><span class="pre">use_default</span></tt> can help to simplify the implementation. Finally,
the identity of the <tt class="literal"><span class="pre">use_default</span></tt> type is not left unspecified
because specification helps to highlight that the <tt class="literal"><span class="pre">Reference</span></tt>
template parameter may not always be identical to the iterator's
<tt class="literal"><span class="pre">reference</span></tt> type, and will keep users making mistakes based on that
assumption.</p>
<tt class="literal"><span class="pre">reference</span></tt> type, and will keep users making mistakes based on
that assumption.</p>
</div>
<div class="section" id="specialized-adaptors">
<h2><a class="toc-backref" href="#id28" name="specialized-adaptors">Specialized Adaptors</a></h2>
@ -697,13 +698,14 @@ Standard compliant iterators).</p>
<h2><a class="toc-backref" href="#id30" name="header-iterator-helper-synopsis-lib-iterator-helper-synopsis">Header <tt class="literal"><span class="pre">&lt;iterator_helper&gt;</span></tt> synopsis [lib.iterator.helper.synopsis]</a></h2>
<pre class="literal-block">
struct use_default;
const unsigned use_default_access = -1;
struct iterator_core_access { /* implementation detail */ };
template &lt;
class Derived
, class Value
, class AccessCategory
, unsigned AccessCategory
, class TraversalCategory
, class Reference = Value&amp;
, class Difference = ptrdiff_t
@ -714,7 +716,8 @@ template &lt;
class Derived
, class Base
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
&gt;
@ -723,7 +726,8 @@ class iterator_adaptor;
template &lt;
class Iterator
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
&gt;
@ -745,7 +749,8 @@ class filter_iterator;
template &lt;
class Incrementable
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Difference = use_default
&gt;
class counting_iterator
@ -765,7 +770,7 @@ and associated types, to be supplied by a derived iterator class.</p>
template &lt;
class Derived
, class Value
, class AccessCategory
, unsigned AccessCategory
, class TraversalCategory
, class Reference = /* see <a class="reference" href="#iterator-facade-requirements">below</a> */
, class Difference = ptrdiff_t
@ -855,11 +860,21 @@ out of the overload set when the types are not interoperable.]</p>
title prevents an automatic link from being generated -->
<a class="target" id="iterator-facade-requirements" name="iterator-facade-requirements"></a><div class="section" id="id13">
<h4><a class="toc-backref" href="#id33" name="id13"><tt class="literal"><span class="pre">iterator_facade</span></tt> requirements</a></h4>
<p>Some of the constraints on template parameters to
<tt class="literal"><span class="pre">iterator_facade</span></tt> are expressed in terms of resulting nested
types and should be viewed in the context of their impact on
<tt class="literal"><span class="pre">iterator_traits&lt;Derived&gt;</span></tt>.</p>
<p>The <tt class="literal"><span class="pre">Derived</span></tt> template parameter must be a class derived from
<tt class="literal"><span class="pre">iterator_facade</span></tt>.</p>
<p>The default for the <tt class="literal"><span class="pre">Reference</span></tt> parameter is <tt class="literal"><span class="pre">Value&amp;</span></tt> if the
access category for <tt class="literal"><span class="pre">iterator_facade</span></tt> is implicitly convertible to
<tt class="literal"><span class="pre">writable_iterator_tag</span></tt>, and <tt class="literal"><span class="pre">const</span> <span class="pre">Value&amp;</span></tt> otherwise.</p>
<p>The nested <tt class="literal"><span class="pre">::value_type</span></tt> type will be the same as
<tt class="literal"><span class="pre">remove_cv&lt;Value&gt;::type</span></tt>, so the <tt class="literal"><span class="pre">Value</span></tt> parameter must be
an (optionally <tt class="literal"><span class="pre">const</span></tt>-qualified) non-reference type.</p>
<p><tt class="literal"><span class="pre">AccessCategory</span></tt> must be an unsigned value which uses no more
bits than the greatest value of <tt class="literal"><span class="pre">iterator_access</span></tt>.</p>
<p>The nested <tt class="literal"><span class="pre">::reference</span></tt> will be the same as the <tt class="literal"><span class="pre">Reference</span></tt>
parameter; it must be a suitable reference type for the resulting
iterator. The default for the <tt class="literal"><span class="pre">Reference</span></tt> parameter is
<tt class="literal"><span class="pre">Value&amp;</span></tt>.</p>
<p>The following table describes the other requirements on the
<tt class="literal"><span class="pre">Derived</span></tt> parameter. Depending on the resulting iterator's
<tt class="literal"><span class="pre">iterator_category</span></tt>, a subset of the expressions listed in the table
@ -973,8 +988,8 @@ of type <tt class="literal"><span class="pre">X::pointer</span></tt> equal to:</
<p>Otherwise returns an object of unspecified type such that, given an
object <tt class="literal"><span class="pre">a</span></tt> of type <tt class="literal"><span class="pre">X</span></tt>, <tt class="literal"><span class="pre">a-&gt;m</span></tt> is equivalent to <tt class="literal"><span class="pre">(w</span> <span class="pre">=</span> <span class="pre">*a,</span>
<span class="pre">w.m)</span></tt> for some temporary object <tt class="literal"><span class="pre">w</span></tt> of type <tt class="literal"><span class="pre">X::value_type</span></tt>.</p>
<p class="last">The type <tt class="literal"><span class="pre">X::pointer</span></tt> is <tt class="literal"><span class="pre">Value*</span></tt> if the access category for
<tt class="literal"><span class="pre">X</span></tt> is implicitly convertible to <tt class="literal"><span class="pre">writable_iterator_tag</span></tt>, and
<p class="last">The type <tt class="literal"><span class="pre">X::pointer</span></tt> is <tt class="literal"><span class="pre">Value*</span></tt> if
<tt class="literal"><span class="pre">is_writable_iterator&lt;X&gt;::value</span></tt> is <tt class="literal"><span class="pre">true</span></tt>, and
<tt class="literal"><span class="pre">Value</span> <span class="pre">const*</span></tt> otherwise.</p>
</td>
</tr>
@ -1107,11 +1122,13 @@ core interface functions of <tt class="literal"><span class="pre">iterator_facad
<div class="section" id="class-template-iterator-adaptor">
<h3><a class="toc-backref" href="#id36" name="class-template-iterator-adaptor">Class template <tt class="literal"><span class="pre">iterator_adaptor</span></tt></a></h3>
<pre class="literal-block">
bool
template &lt;
class Derived
, class Base
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
&gt;
@ -1163,54 +1180,47 @@ parameters specify the types for the member typedefs in
<tt class="literal"><span class="pre">iterator_facade</span></tt>. The following pseudo-code specifies the
traits types for <tt class="literal"><span class="pre">iterator_adaptor</span></tt>.</p>
<pre class="literal-block">
if (Value == use_default)
value_type = iterator_traits&lt;Base&gt;::value_type;
else
value_type = remove_cv&lt;Value&gt;::type;
if (Reference == use_default) {
if (Value == use_default)
reference = iterator_traits&lt;Base&gt;::reference;
else
reference = Value&amp;;
} else
reference = Reference;
if (Distance == use_default)
difference_type = iterator_traits&lt;Base&gt;::difference_type;
if (Value != use_default)
value_type = remove_cv&lt;Value&gt;::type;
else
difference_type = Distance;
value_type = iterator_traits&lt;Base&gt;::value_type;
if (Category == use_default)
iterator_category = iterator_tag&lt;
access_category&lt; Base &gt;,
traversal_category&lt; Base &gt;
&gt;
else if (Category is convertible to a standard access tag)
iterator_category = iterator_tag&lt;
Category
else if (Category has a nested traversal type)
if (reference is not a reference-to-const)
Category::access
else
if (Category
else if (Category is convertable to a standard traversal tag)
...
if (Traversal != use_default)
traversal_category = Traversal
else
iterator_category = Category;
// Actually the above is wrong. See the use of
// access_category_tag and
// new_category_to_access/iter_category_to_access.
traversal_category = traversal_category&lt; Base &gt;::type
iterator_category = iterator_tag&lt;
access_category
, traversal_category
&gt;
if (Access != use_default)
{
access_category = Access
}
else
{
access_category
= access_category&lt; Base &gt;::value
if (is_const&lt;Value&gt;)
access_category &amp;= ~writable_iterator;
}
iterator_category = iterator_tag&lt;
access_category
, traversal_category
&gt;
if (Reference != use_default)
reference = Reference
else if (Value != use_default)
reference = Value&amp;
else
reference = iterator_traits&lt;Base&gt;::reference
</pre>
<!-- Replaced with new semantics - -thw
if (Category == use_default)
iterator_category = iterator_traits<Base>::iterator_category;
else
iterator_category = Category;
Fix this up!! -->
</div>
<div class="section" id="iterator-adaptor-public-operations">
<h3><a class="toc-backref" href="#id38" name="iterator-adaptor-public-operations"><tt class="literal"><span class="pre">iterator_adaptor</span></tt> public operations</a></h3>
@ -1362,7 +1372,8 @@ iterators over smart pointers, which the impl handles. -JGS -->
template &lt;
class Iterator
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
&gt;
@ -1374,12 +1385,12 @@ class indirect_iterator
indirect_iterator();
indirect_iterator(Iterator x);
template &lt;
class Iterator2, class Value2, class Category2
class Iterator2, class Value2, unsigned Access2, class Traversal2
, class Reference2, class Difference2
&gt;
indirect_iterator(
indirect_iterator&lt;
Iterator2, Value2, Category2, Reference2, Difference2
Iterator2, Value2, Access2, Traversal2, Reference2, Difference2
&gt; const&amp; y
, typename enable_if_convertible&lt;Iterator2, Iterator&gt;::type* = 0 // exposition
);
@ -1408,9 +1419,10 @@ specialization of <tt class="literal"><span class="pre">iterator_traits</span></
iterator.</p>
<p>The <tt class="literal"><span class="pre">Reference</span></tt> parameter will be the <tt class="literal"><span class="pre">reference</span></tt> type of the
<tt class="literal"><span class="pre">indirect_iterator</span></tt>. The default is <tt class="literal"><span class="pre">Value&amp;</span></tt>.</p>
<p>The <tt class="literal"><span class="pre">Category</span></tt> parameter is the <tt class="literal"><span class="pre">iterator_category</span></tt> type for the
<tt class="literal"><span class="pre">indirect_iterator</span></tt>. The default is
<tt class="literal"><span class="pre">iterator_traits&lt;Iterator&gt;::iterator_category</span></tt>.</p>
<p>The <tt class="literal"><span class="pre">Access</span></tt> and <tt class="literal"><span class="pre">Traversal</span></tt> parameters are passed unchanged to
the corresponding parameters of the <tt class="literal"><span class="pre">iterator_adaptor</span></tt> base
class, and the <tt class="literal"><span class="pre">Iterator</span></tt> parameter is passed unchanged as the
<tt class="literal"><span class="pre">Base</span></tt> parameter to the <tt class="literal"><span class="pre">iterator_adaptor</span></tt> base class.</p>
<p>The indirect iterator will model the most refined standard traversal
concept that is modeled by the <tt class="literal"><span class="pre">Iterator</span></tt> type. The indirect
iterator will model the most refined standard access concept that is
@ -1442,12 +1454,12 @@ the <tt class="literal"><span class="pre">iterator_adaptor</span></tt> subobject
</table>
<pre class="literal-block">
template &lt;
class Iterator2, class Value2, class Category2
class Iterator2, class Value2, unsigned Access, class Traversal
, class Reference2, class Difference2
&gt;
indirect_iterator(
indirect_iterator&lt;
Iterator2, Value2, Category2, Reference2, Difference2
Iterator2, Value2, Access, Traversal, Reference2, Difference2
&gt; const&amp; y
, typename enable_if_convertible&lt;Iterator2, Iterator&gt;::type* = 0 // exposition
);
@ -1733,12 +1745,13 @@ class filter_iterator
</div>
<div class="section" id="filter-iterator-requirements">
<h3><a class="toc-backref" href="#id56" name="filter-iterator-requirements"><tt class="literal"><span class="pre">filter_iterator</span></tt> requirements</a></h3>
<p>The base <tt class="literal"><span class="pre">Iterator</span></tt> parameter must be a model of Readable Iterator
and Single Pass Iterator. The resulting <tt class="literal"><span class="pre">filter_iterator</span></tt> will be a
model of Forward Traversal Iterator if <tt class="literal"><span class="pre">Iterator</span></tt> is, otherwise the
<tt class="literal"><span class="pre">filter_iterator</span></tt> will be a model of Single Pass Iterator. The
access category of the <tt class="literal"><span class="pre">filter_iterator</span></tt> will be the most refined
standard access category that is modeled by <tt class="literal"><span class="pre">Iterator</span></tt>.</p>
<p>The base <tt class="literal"><span class="pre">Iterator</span></tt> parameter must be a model of Readable
Iterator and Single Pass Iterator. The resulting
<tt class="literal"><span class="pre">filter_iterator</span></tt> will be a model of Forward Traversal Iterator
if <tt class="literal"><span class="pre">Iterator</span></tt> is, otherwise the <tt class="literal"><span class="pre">filter_iterator</span></tt> will be a
model of Single Pass Iterator. The access category of the
<tt class="literal"><span class="pre">filter_iterator</span></tt> will be the same as the access category of
<tt class="literal"><span class="pre">Iterator</span></tt>.</p>
<!-- Thomas is going to try implementing filter_iterator so that
it will be bidirectional if the underlying iterator is. -JGS -->
<p>The <tt class="literal"><span class="pre">Predicate</span></tt> must be Assignable, Copy Constructible, and the
@ -1830,13 +1843,19 @@ the base <tt class="literal"><span class="pre">m_iterator</span></tt>, as per th
<div class="section" id="class-template-counting-iterator">
<h4><a class="toc-backref" href="#id59" name="class-template-counting-iterator">Class template <tt class="literal"><span class="pre">counting_iterator</span></tt></a></h4>
<pre class="literal-block">
template &lt;class Incrementable, class Category = use_default, class Difference = use_default&gt;
template &lt;
class Incrementable
, unsigned Access = use_default_access
, class Traversal = use_default
, class Difference = use_default
&gt;
class counting_iterator
: public iterator_adaptor&lt;
counting_iterator&lt;Incrementable, Category, Difference&gt;
counting_iterator&lt;Incrementable, Access, Traversal, Difference&gt;
, Incrementable
, Incrementable
, /* see details for category */
, Access
, /* see details for traversal category */
, Incrementable const&amp;
, Incrementable const*
, /* distance = Difference or a signed integral type */&gt;
@ -1935,7 +1954,7 @@ template &lt;class UnaryFunction&gt;
class function_output_iterator {
public:
typedef iterator_tag&lt;
writable_iterator_tag
writable_iterator
, incrementable_traversal_tag
&gt; iterator_category;
typedef void value_type;
@ -2043,7 +2062,7 @@ LocalWords: OtherIncrementable Coplien -->
<hr class="footer" />
<div class="footer">
<a class="reference" href="facade-and-adaptor.rst">View document source</a>.
Generated on: 2003-09-22 14:17 UTC.
Generated on: 2003-09-22 16:48 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,7 +8,7 @@
Lab`_, University of Hanover `Institute for Transport
Railway Operation and Construction`_
:date: $Date$
:Number: **This document is a revised version of the official** N1476=03-0059
:Number: N1530=03-0113
:copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved
.. _`Boost Consulting`: http://www.boost-consulting.com
@ -226,13 +226,14 @@ Header ``<iterator_helper>`` synopsis [lib.iterator.helper.synopsis]
::
struct use_default;
const unsigned use_default_access = -1;
struct iterator_core_access { /* implementation detail */ };
template <
class Derived
, class Value
, class AccessCategory
, unsigned AccessCategory
, class TraversalCategory
, class Reference = Value&
, class Difference = ptrdiff_t
@ -243,7 +244,8 @@ Header ``<iterator_helper>`` synopsis [lib.iterator.helper.synopsis]
class Derived
, class Base
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
>
@ -252,7 +254,8 @@ Header ``<iterator_helper>`` synopsis [lib.iterator.helper.synopsis]
template <
class Iterator
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
>
@ -274,7 +277,8 @@ Header ``<iterator_helper>`` synopsis [lib.iterator.helper.synopsis]
template <
class Incrementable
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Difference = use_default
>
class counting_iterator

View File

@ -41,12 +41,13 @@
``filter_iterator`` requirements
--------------------------------
The base ``Iterator`` parameter must be a model of Readable Iterator
and Single Pass Iterator. The resulting ``filter_iterator`` will be a
model of Forward Traversal Iterator if ``Iterator`` is, otherwise the
``filter_iterator`` will be a model of Single Pass Iterator. The
access category of the ``filter_iterator`` will be the most refined
standard access category that is modeled by ``Iterator``.
The base ``Iterator`` parameter must be a model of Readable
Iterator and Single Pass Iterator. The resulting
``filter_iterator`` will be a model of Forward Traversal Iterator
if ``Iterator`` is, otherwise the ``filter_iterator`` will be a
model of Single Pass Iterator. The access category of the
``filter_iterator`` will be the same as the access category of
``Iterator``.
.. Thomas is going to try implementing filter_iterator so that
it will be bidirectional if the underlying iterator is. -JGS

View File

@ -4,7 +4,7 @@
class function_output_iterator {
public:
typedef iterator_tag<
writable_iterator_tag
writable_iterator
, incrementable_traversal_tag
> iterator_category;
typedef void value_type;

View File

@ -3,7 +3,8 @@
template <
class Iterator
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
>
@ -15,12 +16,12 @@
indirect_iterator();
indirect_iterator(Iterator x);
template <
class Iterator2, class Value2, class Category2
class Iterator2, class Value2, unsigned Access2, class Traversal2
, class Reference2, class Difference2
>
indirect_iterator(
indirect_iterator<
Iterator2, Value2, Category2, Reference2, Difference2
Iterator2, Value2, Access2, Traversal2, Reference2, Difference2
> const& y
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
);
@ -53,9 +54,10 @@ iterator.
The ``Reference`` parameter will be the ``reference`` type of the
``indirect_iterator``. The default is ``Value&``.
The ``Category`` parameter is the ``iterator_category`` type for the
``indirect_iterator``. The default is
``iterator_traits<Iterator>::iterator_category``.
The ``Access`` and ``Traversal`` parameters are passed unchanged to
the corresponding parameters of the ``iterator_adaptor`` base
class, and the ``Iterator`` parameter is passed unchanged as the
``Base`` parameter to the ``iterator_adaptor`` base class.
The indirect iterator will model the most refined standard traversal
concept that is modeled by the ``Iterator`` type. The indirect
@ -81,12 +83,12 @@ modeled by the value type of ``Iterator``.
::
template <
class Iterator2, class Value2, class Category2
class Iterator2, class Value2, unsigned Access, class Traversal
, class Reference2, class Difference2
>
indirect_iterator(
indirect_iterator<
Iterator2, Value2, Category2, Reference2, Difference2
Iterator2, Value2, Access, Traversal, Reference2, Difference2
> const& y
, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // exposition
);

View File

@ -18,15 +18,16 @@ iterator. It need only support the operations used by the core
interface functions of ``iterator_adaptor`` that have not been
redefined in the user's derived class.
Several of the template parameters of ``iterator_adaptor`` default to
``use_default``. This allows the user to make use of a default
parameter even when the user wants to specify a parameter later in the
parameter list. Also, the defaults for the corresponding associated
types are fairly complicated, so metaprogramming is required to
compute them, and ``use_default`` can help to simplify the
implementation. Finally, ``use_default`` is not left unspecified
Several of the template parameters of ``iterator_adaptor`` default
to ``use_default`` (or ``use_default_access``). This allows the
user to make use of a default parameter even when she wants to
specify a parameter later in the parameter list. Also, the
defaults for the corresponding associated types are somewhat
complicated, so metaprogramming is required to compute them, and
``use_default`` can help to simplify the implementation. Finally,
the identity of the ``use_default`` type is not left unspecified
because specification helps to highlight that the ``Reference``
template parameter may not always be identical to the iterator's
``reference`` type, and will keep users making mistakes based on that
assumption.
``reference`` type, and will keep users making mistakes based on
that assumption.

View File

@ -1,10 +1,12 @@
.. parsed-literal::
bool
template <
class Derived
, class Base
, class Value = use_default
, class Category = use_default
, unsigned Access = use_default_access
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
>
@ -60,55 +62,46 @@ traits types for ``iterator_adaptor``.
::
if (Value == use_default)
value_type = iterator_traits<Base>::value_type;
else
if (Value != use_default)
value_type = remove_cv<Value>::type;
if (Reference == use_default) {
if (Value == use_default)
reference = iterator_traits<Base>::reference;
else
reference = Value&;
} else
reference = Reference;
if (Distance == use_default)
difference_type = iterator_traits<Base>::difference_type;
else
difference_type = Distance;
if (Category == use_default)
iterator_category = iterator_tag<
access_category< Base >,
traversal_category< Base >
>
else if (Category is convertible to a standard access tag)
iterator_category = iterator_tag<
Category
else if (Category has a nested traversal type)
if (reference is not a reference-to-const)
Category::access
else
if (Category
else if (Category is convertable to a standard traversal tag)
...
else
iterator_category = Category;
// Actually the above is wrong. See the use of
// access_category_tag and
// new_category_to_access/iter_category_to_access.
else
value_type = iterator_traits<Base>::value_type;
.. Replaced with new semantics --thw
if (Category == use_default)
iterator_category = iterator_traits<Base>::iterator_category;
else
iterator_category = Category;
if (Traversal != use_default)
traversal_category = Traversal
else
traversal_category = traversal_category< Base >::type
Fix this up!!
iterator_category = iterator_tag<
access_category
, traversal_category
>
if (Access != use_default)
{
access_category = Access
}
else
{
access_category
= access_category< Base >::value
if (is_const<Value>)
access_category &= ~writable_iterator;
}
iterator_category = iterator_tag<
access_category
, traversal_category
>
if (Reference != use_default)
reference = Reference
else if (Value != use_default)
reference = Value&
else
reference = iterator_traits<Base>::reference
``iterator_adaptor`` public operations

View File

@ -3,7 +3,7 @@
template <
class Derived
, class Value
, class AccessCategory
, unsigned AccessCategory
, class TraversalCategory
, class Reference = /* see below__ \*/
, class Difference = ptrdiff_t
@ -108,12 +108,25 @@ out of the overload set when the types are not interoperable.]
``iterator_facade`` requirements
................................
Some of the constraints on template parameters to
``iterator_facade`` are expressed in terms of resulting nested
types and should be viewed in the context of their impact on
``iterator_traits<Derived>``.
The ``Derived`` template parameter must be a class derived from
``iterator_facade``.
The default for the ``Reference`` parameter is ``Value&`` if the
access category for ``iterator_facade`` is implicitly convertible to
``writable_iterator_tag``, and ``const Value&`` otherwise.
The nested ``::value_type`` type will be the same as
``remove_cv<Value>::type``, so the ``Value`` parameter must be
an (optionally ``const``\ -qualified) non-reference type.
``AccessCategory`` must be an unsigned value which uses no more
bits than the greatest value of ``iterator_access``.
The nested ``::reference`` will be the same as the ``Reference``
parameter; it must be a suitable reference type for the resulting
iterator. The default for the ``Reference`` parameter is
``Value&``.
The following table describes the other requirements on the
``Derived`` parameter. Depending on the resulting iterator's
@ -188,8 +201,8 @@ __ `operator arrow`_
object ``a`` of type ``X``, ``a->m`` is equivalent to ``(w = *a,
w.m)`` for some temporary object ``w`` of type ``X::value_type``.
The type ``X::pointer`` is ``Value*`` if the access category for
``X`` is implicitly convertible to ``writable_iterator_tag``, and
The type ``X::pointer`` is ``Value*`` if
``is_writable_iterator<X>::value`` is ``true``, and
``Value const*`` otherwise.

View File

@ -3,13 +3,204 @@
<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.0: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.3.1: 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-09-22" />
<meta name="copyright" content="Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved" />
<link rel="stylesheet" href="default.css" type="text/css" />
<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>
</head>
<body>
<div class="document" id="new-iterator-concepts">
@ -963,5 +1154,11 @@ LocalWords: TraversalTag typename lvalues DWA Hmm JGS mis enum -->
</div>
</div>
</div>
<hr class="footer" />
<div class="footer">
<a class="reference" href="new-iter-concepts.rst">View document source</a>.
Generated on: 2003-09-22 19:48 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>

View File

@ -3,7 +3,8 @@
template< class ElementIterator
, class IndexIterator
, class ValueT = use_default
, class CategoryT = use_default
, unsigned access = use_default_access
, class Traversal = use_default
, class ReferenceT = use_default
, class DifferenceT = use_default >
class permutation_iterator

78
doc/style.tex Executable file
View File

@ -0,0 +1,78 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%% docutils.sty: A style for docutils latex output %%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% o author: Alexander Schmolck (a.schmolck@gmx.net)
%% o created: 2002-07-07 10:50:31+00:40
%% o last modified: $Date: 2003/09/22 19:55:01 $
%% o keywords:
%% o license:
%XXX titlesec
%% XXX geometry
\usepackage{graphicx}
\usepackage{latexsym} % extra symbols
\usepackage{url} % !!!: pay attention when using in other commands!!!
\usepackage{verbatim} % normal verbatim has lenght-limit
\usepackage{enumerate} % easy style choice with e.g: ``\begin{enumerate}[Ex i.]``
\usepackage{hyperref} %href, htarget and hlink XXX: pdfauthor, pdfcreator etc.
\usepackage{xr} %XXX do we need this?
% need this to have ``fboxes`` in ``enviroments``, as well as ``verbatim``s
\usepackage{fancybox}
\usepackage{mdwtab} % better tables and arrays (fixes spacing and adds
% vertical align and multirows (m))
\usepackage{ltxtable} % long and autoscaling tables (use X for autoscaled
% columns)
\newcommand{\transition}{\vspace{2em}\par\hrule{}\par\vspace{2em}}
\newcommand{\classifier}[1]{(\textit{#1})}
\newenvironment{topic}[1]%
{\begin{Sbox}%
\begin{minipage}{.8\textwidth}%
\protect{\large{\textbf{#1}}}\par\vspace{.5em}}%
{\end{minipage}\end{Sbox}\fbox{\TheSbox}\par\vspace{.5em}}
%XXX shadow box for warnings?
\newenvironment{admonition}[1]%
{\begin{center}%
\begin{Sbox}%
\begin{minipage}{.9\textwidth}%
\protect{\textsc{#1}}\par\vspace{.2em}}%
{\end{minipage}\end{Sbox}\fbox{\TheSbox}\par\vspace{.5em}\end{center}}
\newenvironment{doctest}%
{\VerbatimEnvironment
\begin{Verbatim}}%
{\end{Verbatim}}
% {%
% \begin{Sbox}%
% \begin{minipage}{.8\textwidth}%
% \protect{\large{\textsc{#1}}\par\vspace{.5em}}}%
% {\end{minipage}\end{Sbox}\fbox{\TheSbox}\par\vspace{.5em}}
%{\end{minipage}\end{Sbox}\fbox{\TheSbox}}
%% just a piece of example code
% \newcommand{\vitem}%
% {\SaveVerb[{\item[\UseVerb{\MyTemp}]}]{\MyTemp}}
%%%%%%%%%%%%%%%%%%% Added by DWA %%%%%%%%%%%%%%%%%%%%%%%%%
% donot indent first line.
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt plus 2pt minus 1pt}
% sloppy
% ------
% Less strict (opposite to default fussy) space size between words. Therefore
% less hyphenation.
\sloppy
% fonts
% -----
% times for pdf generation, gives smaller pdf files.
%
% But in standard postscript fonts: courier and times/helvetica do not fit.
% Maybe use pslatex.
\usepackage{times}
\usepackage{pslatex}
% pagestyle
\pagestyle{headings}