mirror of
https://github.com/boostorg/iterator.git
synced 2025-07-20 16:12:10 +02:00
add nested typedefs
[SVN r23644]
This commit is contained in:
@ -614,7 +614,7 @@ template <
|
|||||||
, class Difference = ptrdiff_t
|
, class Difference = ptrdiff_t
|
||||||
>
|
>
|
||||||
class iterator_facade {
|
class iterator_facade {
|
||||||
public:
|
public:
|
||||||
typedef remove_const<Value>::type value_type;
|
typedef remove_const<Value>::type value_type;
|
||||||
typedef Reference reference;
|
typedef Reference reference;
|
||||||
typedef Value* pointer;
|
typedef Value* pointer;
|
||||||
@ -631,6 +631,8 @@ public:
|
|||||||
Derived& operator+=(difference_type n);
|
Derived& operator+=(difference_type n);
|
||||||
Derived& operator-=(difference_type n);
|
Derived& operator-=(difference_type n);
|
||||||
Derived operator-(difference_type n) const;
|
Derived operator-(difference_type n) const;
|
||||||
|
protected:
|
||||||
|
typedef iterator_facade iterator_facade_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Comparison operators
|
// Comparison operators
|
||||||
@ -1202,6 +1204,7 @@ class iterator_adaptor
|
|||||||
explicit iterator_adaptor(Base iter);
|
explicit iterator_adaptor(Base iter);
|
||||||
Base const& base() const;
|
Base const& base() const;
|
||||||
protected:
|
protected:
|
||||||
|
typedef iterator_adaptor iterator_adaptor_;
|
||||||
Base const& base_reference() const;
|
Base const& base_reference() const;
|
||||||
Base& base_reference();
|
Base& base_reference();
|
||||||
private: // Core iterator interface for iterator_facade.
|
private: // Core iterator interface for iterator_facade.
|
||||||
|
Binary file not shown.
@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<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.3.4: http://docutils.sourceforge.net/" />
|
||||||
<title>Iterator Adaptor</title>
|
<title>Iterator Adaptor</title>
|
||||||
<meta name="author" content="David Abrahams, Jeremy Siek, Thomas Witt" />
|
<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="organization" content="Boost Consulting, Indiana University Open Systems Lab, University of Hanover Institute for Transport Railway Operation and Construction" />
|
||||||
@ -12,7 +12,6 @@
|
|||||||
<link rel="stylesheet" href="default.css" type="text/css" />
|
<link rel="stylesheet" href="default.css" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="document" id="iterator-adaptor">
|
|
||||||
<h1 class="title">Iterator Adaptor</h1>
|
<h1 class="title">Iterator Adaptor</h1>
|
||||||
<table class="docinfo" frame="void" rules="none">
|
<table class="docinfo" frame="void" rules="none">
|
||||||
<col class="docinfo-name" />
|
<col class="docinfo-name" />
|
||||||
@ -32,6 +31,7 @@ Railway Operation and Construction</a></td></tr>
|
|||||||
<td>Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved</td></tr>
|
<td>Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="document" id="iterator-adaptor">
|
||||||
<table class="field-list" frame="void" rules="none">
|
<table class="field-list" frame="void" rules="none">
|
||||||
<col class="field-name" />
|
<col class="field-name" />
|
||||||
<col class="field-body" />
|
<col class="field-body" />
|
||||||
@ -55,7 +55,7 @@ depends on the operations supported by the <tt class="literal"><span class="pre"
|
|||||||
core interface functions of <tt class="literal"><span class="pre">iterator_facade</span></tt> are redefined in the
|
core interface functions of <tt class="literal"><span class="pre">iterator_facade</span></tt> are redefined in the
|
||||||
<tt class="literal"><span class="pre">Derived</span></tt> class.</p>
|
<tt class="literal"><span class="pre">Derived</span></tt> class.</p>
|
||||||
<div class="contents topic" id="table-of-contents">
|
<div class="contents topic" id="table-of-contents">
|
||||||
<p class="topic-title"><a name="table-of-contents">Table of Contents</a></p>
|
<p class="topic-title first"><a name="table-of-contents">Table of Contents</a></p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference" href="#overview" id="id6" name="id6">Overview</a></li>
|
<li><a class="reference" href="#overview" id="id6" name="id6">Overview</a></li>
|
||||||
<li><a class="reference" href="#reference" id="id7" name="id7">Reference</a><ul>
|
<li><a class="reference" href="#reference" id="id7" name="id7">Reference</a><ul>
|
||||||
@ -135,6 +135,7 @@ class iterator_adaptor
|
|||||||
explicit iterator_adaptor(Base iter);
|
explicit iterator_adaptor(Base iter);
|
||||||
Base const& base() const;
|
Base const& base() const;
|
||||||
protected:
|
protected:
|
||||||
|
typedef iterator_adaptor iterator_adaptor_;
|
||||||
Base const& base_reference() const;
|
Base const& base_reference() const;
|
||||||
Base& base_reference();
|
Base& base_reference();
|
||||||
private: // Core iterator interface for iterator_facade.
|
private: // Core iterator interface for iterator_facade.
|
||||||
@ -339,7 +340,7 @@ template we developed in the <a class="reference" href="iterator_facade.html#tut
|
|||||||
read that material, you should go back now and check it out because
|
read that material, you should go back now and check it out because
|
||||||
we're going to pick up right where it left off.</p>
|
we're going to pick up right where it left off.</p>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<p class="sidebar-title"><tt class="literal"><span class="pre">node_base*</span></tt> really <em>is</em> an iterator</p>
|
<p class="sidebar-title first"><tt class="literal"><span class="pre">node_base*</span></tt> really <em>is</em> an iterator</p>
|
||||||
<p>It's not really a very interesting iterator, since <tt class="literal"><span class="pre">node_base</span></tt>
|
<p>It's not really a very interesting iterator, since <tt class="literal"><span class="pre">node_base</span></tt>
|
||||||
is an abstract class: a pointer to a <tt class="literal"><span class="pre">node_base</span></tt> just points
|
is an abstract class: a pointer to a <tt class="literal"><span class="pre">node_base</span></tt> just points
|
||||||
at some base subobject of an instance of some other class, and
|
at some base subobject of an instance of some other class, and
|
||||||
@ -349,7 +350,7 @@ position is to compare another <tt class="literal"><span class="pre">node_base*<
|
|||||||
words, the original iterator traverses a one-element array.</p>
|
words, the original iterator traverses a one-element array.</p>
|
||||||
</div>
|
</div>
|
||||||
<p>You probably didn't think of it this way, but the <tt class="literal"><span class="pre">node_base*</span></tt>
|
<p>You probably didn't think of it this way, but the <tt class="literal"><span class="pre">node_base*</span></tt>
|
||||||
object which underlies <tt class="literal"><span class="pre">node_iterator</span></tt> is itself an iterator,
|
object that underlies <tt class="literal"><span class="pre">node_iterator</span></tt> is itself an iterator,
|
||||||
just like all other pointers. If we examine that pointer closely
|
just like all other pointers. If we examine that pointer closely
|
||||||
from an iterator perspective, we can see that it has much in common
|
from an iterator perspective, we can see that it has much in common
|
||||||
with the <tt class="literal"><span class="pre">node_iterator</span></tt> we're building. First, they share most
|
with the <tt class="literal"><span class="pre">node_iterator</span></tt> we're building. First, they share most
|
||||||
@ -358,9 +359,10 @@ of the same associated types (<tt class="literal"><span class="pre">value_type</
|
|||||||
core functionality is the same: <tt class="literal"><span class="pre">operator*</span></tt> and <tt class="literal"><span class="pre">operator==</span></tt> on
|
core functionality is the same: <tt class="literal"><span class="pre">operator*</span></tt> and <tt class="literal"><span class="pre">operator==</span></tt> on
|
||||||
the <tt class="literal"><span class="pre">node_iterator</span></tt> return the result of invoking the same
|
the <tt class="literal"><span class="pre">node_iterator</span></tt> return the result of invoking the same
|
||||||
operations on the underlying pointer, via the <tt class="literal"><span class="pre">node_iterator</span></tt>'s
|
operations on the underlying pointer, via the <tt class="literal"><span class="pre">node_iterator</span></tt>'s
|
||||||
<a class="reference" href="iterator_facade.html#implementing-the-core-operations"><tt class="literal"><span class="pre">dereference</span></tt> and <tt class="literal"><span class="pre">equal</span></tt> member functions</a>). However, the <tt class="literal"><span class="pre">operator++</span></tt> for
|
<a class="reference" href="iterator_facade.html#implementing-the-core-operations"><tt class="literal"><span class="pre">dereference</span></tt> and <tt class="literal"><span class="pre">equal</span></tt> member functions</a>). The only real behavioral difference
|
||||||
<tt class="literal"><span class="pre">node_iterator</span></tt> behaves differently than for <tt class="literal"><span class="pre">node_base*</span></tt>
|
between <tt class="literal"><span class="pre">node_base*</span></tt> and <tt class="literal"><span class="pre">node_iterator</span></tt> can be observed when
|
||||||
since it follows the <tt class="literal"><span class="pre">m_next</span></tt> pointer.</p>
|
they are incremented: <tt class="literal"><span class="pre">node_iterator</span></tt> follows the
|
||||||
|
<tt class="literal"><span class="pre">m_next</span></tt> pointer, while <tt class="literal"><span class="pre">node_base*</span></tt> just applies an address offset.</p>
|
||||||
<p>It turns out that the pattern of building an iterator on another
|
<p>It turns out that the pattern of building an iterator on another
|
||||||
iterator-like type (the <tt class="literal"><span class="pre">Base</span></tt> <a class="footnote-reference" href="#base" id="id3" name="id3"><sup>1</sup></a> type) while modifying
|
iterator-like type (the <tt class="literal"><span class="pre">Base</span></tt> <a class="footnote-reference" href="#base" id="id3" name="id3"><sup>1</sup></a> type) while modifying
|
||||||
just a few aspects of the underlying type's behavior is an
|
just a few aspects of the underlying type's behavior is an
|
||||||
@ -384,16 +386,12 @@ class node_iter
|
|||||||
private:
|
private:
|
||||||
struct enabler {}; // a private type avoids misuse
|
struct enabler {}; // a private type avoids misuse
|
||||||
|
|
||||||
typedef boost::iterator_adaptor<
|
|
||||||
node_iter<Value>, Value*, boost::use_default, boost::forward_traversal_tag
|
|
||||||
> super_t;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
node_iter()
|
node_iter()
|
||||||
: super_t(0) {}
|
: node_iter::iterator_adaptor_(0) {}
|
||||||
|
|
||||||
explicit node_iter(Value* p)
|
explicit node_iter(Value* p)
|
||||||
: super_t(p) {}
|
: node_iter::iterator_adaptor_(p) {}
|
||||||
|
|
||||||
template <class OtherValue>
|
template <class OtherValue>
|
||||||
node_iter(
|
node_iter(
|
||||||
@ -403,14 +401,20 @@ class node_iter
|
|||||||
, enabler
|
, enabler
|
||||||
>::type = enabler()
|
>::type = enabler()
|
||||||
)
|
)
|
||||||
: super_t(other.base()) {}
|
: node_iter::iterator_adaptor_(other.base()) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
void increment() { this->base_reference() = this->base()->next(); }
|
void increment() { this->base_reference() = this->base()->next(); }
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
<p>You can see an example program which exercises this version of the
|
<p>Note the use of <tt class="literal"><span class="pre">node_iter::iterator_adaptor_</span></tt> here: because
|
||||||
|
<tt class="literal"><span class="pre">iterator_adaptor</span></tt> defines a nested <tt class="literal"><span class="pre">iterator_adaptor_</span></tt> type
|
||||||
|
that refers to itself, that gives us a convenient way to refer to
|
||||||
|
the complicated base class type of <tt class="literal"><span class="pre">node_iter<Value></span></tt>. [Note:
|
||||||
|
this technique is known not to work with Borland C++ 5.6.4 and
|
||||||
|
Metrowerks CodeWarrior versions prior to 9.0]</p>
|
||||||
|
<p>You can see an example program that exercises this version of the
|
||||||
node iterators <a class="reference" href="../example/node_iterator3.cpp">here</a>.</p>
|
node iterators <a class="reference" href="../example/node_iterator3.cpp">here</a>.</p>
|
||||||
<p>In the case of <tt class="literal"><span class="pre">node_iter</span></tt>, it's not very compelling to pass
|
<p>In the case of <tt class="literal"><span class="pre">node_iter</span></tt>, it's not very compelling to pass
|
||||||
<tt class="literal"><span class="pre">boost::use_default</span></tt> as <tt class="literal"><span class="pre">iterator_adaptor</span></tt>'s <tt class="literal"><span class="pre">Value</span></tt>
|
<tt class="literal"><span class="pre">boost::use_default</span></tt> as <tt class="literal"><span class="pre">iterator_adaptor</span></tt>'s <tt class="literal"><span class="pre">Value</span></tt>
|
||||||
@ -423,7 +427,7 @@ iterator type argument and reverses its direction of traversal,
|
|||||||
since the original iterator and the reversed one have all the same
|
since the original iterator and the reversed one have all the same
|
||||||
associated types, <tt class="literal"><span class="pre">iterator_adaptor</span></tt>'s delegation of default
|
associated types, <tt class="literal"><span class="pre">iterator_adaptor</span></tt>'s delegation of default
|
||||||
types to its <tt class="literal"><span class="pre">Base</span></tt> saves the implementor of
|
types to its <tt class="literal"><span class="pre">Base</span></tt> saves the implementor of
|
||||||
<tt class="literal"><span class="pre">boost::reverse_iterator</span></tt> from writing</p>
|
<tt class="literal"><span class="pre">boost::reverse_iterator</span></tt> from writing:</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
std::iterator_traits<Iterator>::<em>some-associated-type</em>
|
std::iterator_traits<Iterator>::<em>some-associated-type</em>
|
||||||
</pre>
|
</pre>
|
||||||
|
Binary file not shown.
@ -23,6 +23,7 @@
|
|||||||
explicit iterator_adaptor(Base iter);
|
explicit iterator_adaptor(Base iter);
|
||||||
Base const& base() const;
|
Base const& base() const;
|
||||||
protected:
|
protected:
|
||||||
|
typedef iterator_adaptor iterator_adaptor\_;
|
||||||
Base const& base_reference() const;
|
Base const& base_reference() const;
|
||||||
Base& base_reference();
|
Base& base_reference();
|
||||||
private: // Core iterator interface for iterator_facade.
|
private: // Core iterator interface for iterator_facade.
|
||||||
|
@ -21,7 +21,7 @@ we're going to pick up right where it left off.
|
|||||||
words, the original iterator traverses a one-element array.
|
words, the original iterator traverses a one-element array.
|
||||||
|
|
||||||
You probably didn't think of it this way, but the ``node_base*``
|
You probably didn't think of it this way, but the ``node_base*``
|
||||||
object which underlies ``node_iterator`` is itself an iterator,
|
object that underlies ``node_iterator`` is itself an iterator,
|
||||||
just like all other pointers. If we examine that pointer closely
|
just like all other pointers. If we examine that pointer closely
|
||||||
from an iterator perspective, we can see that it has much in common
|
from an iterator perspective, we can see that it has much in common
|
||||||
with the ``node_iterator`` we're building. First, they share most
|
with the ``node_iterator`` we're building. First, they share most
|
||||||
@ -30,9 +30,10 @@ of the same associated types (``value_type``, ``reference``,
|
|||||||
core functionality is the same: ``operator*`` and ``operator==`` on
|
core functionality is the same: ``operator*`` and ``operator==`` on
|
||||||
the ``node_iterator`` return the result of invoking the same
|
the ``node_iterator`` return the result of invoking the same
|
||||||
operations on the underlying pointer, via the ``node_iterator``\ 's
|
operations on the underlying pointer, via the ``node_iterator``\ 's
|
||||||
|dereference_and_equal|_). However, the ``operator++`` for
|
|dereference_and_equal|_). The only real behavioral difference
|
||||||
``node_iterator`` behaves differently than for ``node_base*``
|
between ``node_base*`` and ``node_iterator`` can be observed when
|
||||||
since it follows the ``m_next`` pointer.
|
they are incremented: ``node_iterator`` follows the
|
||||||
|
``m_next`` pointer, while ``node_base*`` just applies an address offset.
|
||||||
|
|
||||||
.. |dereference_and_equal| replace:: ``dereference`` and ``equal`` member functions
|
.. |dereference_and_equal| replace:: ``dereference`` and ``equal`` member functions
|
||||||
.. _dereference_and_equal: iterator_facade.html#implementing-the-core-operations
|
.. _dereference_and_equal: iterator_facade.html#implementing-the-core-operations
|
||||||
@ -60,16 +61,12 @@ behaviors other than ``increment``. The implementation of
|
|||||||
private:
|
private:
|
||||||
struct enabler {}; // a private type avoids misuse
|
struct enabler {}; // a private type avoids misuse
|
||||||
|
|
||||||
typedef boost::iterator_adaptor<
|
|
||||||
node_iter<Value>, Value*, boost::use_default, boost::forward_traversal_tag
|
|
||||||
> super_t;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
node_iter()
|
node_iter()
|
||||||
: super_t(0) {}
|
: node_iter::iterator_adaptor_(0) {}
|
||||||
|
|
||||||
explicit node_iter(Value* p)
|
explicit node_iter(Value* p)
|
||||||
: super_t(p) {}
|
: node_iter::iterator_adaptor_(p) {}
|
||||||
|
|
||||||
template <class OtherValue>
|
template <class OtherValue>
|
||||||
node_iter(
|
node_iter(
|
||||||
@ -79,14 +76,21 @@ behaviors other than ``increment``. The implementation of
|
|||||||
, enabler
|
, enabler
|
||||||
>::type = enabler()
|
>::type = enabler()
|
||||||
)
|
)
|
||||||
: super_t(other.base()) {}
|
: node_iter::iterator_adaptor_(other.base()) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
void increment() { this->base_reference() = this->base()->next(); }
|
void increment() { this->base_reference() = this->base()->next(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
You can see an example program which exercises this version of the
|
Note the use of ``node_iter::iterator_adaptor_`` here: because
|
||||||
|
``iterator_adaptor`` defines a nested ``iterator_adaptor_`` type
|
||||||
|
that refers to itself, that gives us a convenient way to refer to
|
||||||
|
the complicated base class type of ``node_iter<Value>``. [Note:
|
||||||
|
this technique is known not to work with Borland C++ 5.6.4 and
|
||||||
|
Metrowerks CodeWarrior versions prior to 9.0]
|
||||||
|
|
||||||
|
You can see an example program that exercises this version of the
|
||||||
node iterators `here`__.
|
node iterators `here`__.
|
||||||
|
|
||||||
__ ../example/node_iterator3.cpp
|
__ ../example/node_iterator3.cpp
|
||||||
@ -102,7 +106,7 @@ iterator type argument and reverses its direction of traversal,
|
|||||||
since the original iterator and the reversed one have all the same
|
since the original iterator and the reversed one have all the same
|
||||||
associated types, ``iterator_adaptor``\ 's delegation of default
|
associated types, ``iterator_adaptor``\ 's delegation of default
|
||||||
types to its ``Base`` saves the implementor of
|
types to its ``Base`` saves the implementor of
|
||||||
``boost::reverse_iterator`` from writing
|
``boost::reverse_iterator`` from writing:
|
||||||
|
|
||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<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.3.4: http://docutils.sourceforge.net/" />
|
||||||
<title>Iterator Facade</title>
|
<title>Iterator Facade</title>
|
||||||
<meta name="author" content="David Abrahams, Jeremy Siek, Thomas Witt" />
|
<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="organization" content="Boost Consulting, Indiana University Open Systems Lab, University of Hanover Institute for Transport Railway Operation and Construction" />
|
||||||
@ -12,7 +12,6 @@
|
|||||||
<link rel="stylesheet" href="default.css" type="text/css" />
|
<link rel="stylesheet" href="default.css" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="document" id="iterator-facade">
|
|
||||||
<h1 class="title">Iterator Facade</h1>
|
<h1 class="title">Iterator Facade</h1>
|
||||||
<table class="docinfo" frame="void" rules="none">
|
<table class="docinfo" frame="void" rules="none">
|
||||||
<col class="docinfo-name" />
|
<col class="docinfo-name" />
|
||||||
@ -32,6 +31,7 @@ Railway Operation and Construction</a></td></tr>
|
|||||||
<td>Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved</td></tr>
|
<td>Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. All rights reserved</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="document" id="iterator-facade">
|
||||||
<table class="field-list" frame="void" rules="none">
|
<table class="field-list" frame="void" rules="none">
|
||||||
<col class="field-name" />
|
<col class="field-name" />
|
||||||
<col class="field-body" />
|
<col class="field-body" />
|
||||||
@ -43,7 +43,7 @@ and associated types, to be supplied by a derived iterator class.</td>
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="contents topic" id="table-of-contents">
|
<div class="contents topic" id="table-of-contents">
|
||||||
<p class="topic-title"><a name="table-of-contents">Table of Contents</a></p>
|
<p class="topic-title first"><a name="table-of-contents">Table of Contents</a></p>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference" href="#overview" id="id23" name="id23">Overview</a><ul>
|
<li><a class="reference" href="#overview" id="id23" name="id23">Overview</a><ul>
|
||||||
<li><a class="reference" href="#usage" id="id24" name="id24">Usage</a></li>
|
<li><a class="reference" href="#usage" id="id24" name="id24">Usage</a></li>
|
||||||
@ -143,7 +143,7 @@ of the derived iterator type. These member functions are described
|
|||||||
briefly below and in more detail in the iterator facade
|
briefly below and in more detail in the iterator facade
|
||||||
requirements.</p>
|
requirements.</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<table border class="table">
|
<table border="1" class="table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col width="44%" />
|
<col width="44%" />
|
||||||
<col width="56%" />
|
<col width="56%" />
|
||||||
@ -261,7 +261,6 @@ are described in terms of a set of requirements, which must be
|
|||||||
satisfied by the <tt class="literal"><span class="pre">iterator_facade</span></tt> implementation.</p>
|
satisfied by the <tt class="literal"><span class="pre">iterator_facade</span></tt> implementation.</p>
|
||||||
<table class="citation" frame="void" id="cop95" rules="none">
|
<table class="citation" frame="void" id="cop95" rules="none">
|
||||||
<colgroup><col class="label" /><col /></colgroup>
|
<colgroup><col class="label" /><col /></colgroup>
|
||||||
<col />
|
|
||||||
<tbody valign="top">
|
<tbody valign="top">
|
||||||
<tr><td class="label"><a name="cop95">[Cop95]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id10">2</a>)</em> [Coplien, 1995] Coplien, J., Curiously Recurring Template
|
<tr><td class="label"><a name="cop95">[Cop95]</a></td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id10">2</a>)</em> [Coplien, 1995] Coplien, J., Curiously Recurring Template
|
||||||
Patterns, C++ Report, February 1995, pp. 24-27.</td></tr>
|
Patterns, C++ Report, February 1995, pp. 24-27.</td></tr>
|
||||||
@ -284,7 +283,7 @@ template <
|
|||||||
, class Difference = ptrdiff_t
|
, class Difference = ptrdiff_t
|
||||||
>
|
>
|
||||||
class iterator_facade {
|
class iterator_facade {
|
||||||
public:
|
public:
|
||||||
typedef remove_const<Value>::type value_type;
|
typedef remove_const<Value>::type value_type;
|
||||||
typedef Reference reference;
|
typedef Reference reference;
|
||||||
typedef Value* pointer;
|
typedef Value* pointer;
|
||||||
@ -301,6 +300,8 @@ public:
|
|||||||
Derived& operator+=(difference_type n);
|
Derived& operator+=(difference_type n);
|
||||||
Derived& operator-=(difference_type n);
|
Derived& operator-=(difference_type n);
|
||||||
Derived operator-(difference_type n) const;
|
Derived operator-(difference_type n) const;
|
||||||
|
protected:
|
||||||
|
typedef iterator_facade iterator_facade_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Comparison operators
|
// Comparison operators
|
||||||
@ -444,8 +445,8 @@ object of a single pass iterator type interoperable with <tt class="literal"><sp
|
|||||||
is a constant object of a random access traversal iterator type
|
is a constant object of a random access traversal iterator type
|
||||||
interoperable with <tt class="literal"><span class="pre">X</span></tt>.</p>
|
interoperable with <tt class="literal"><span class="pre">X</span></tt>.</p>
|
||||||
<a class="target" id="core-operations" name="core-operations"></a><div class="topic">
|
<a class="target" id="core-operations" name="core-operations"></a><div class="topic">
|
||||||
<p class="topic-title"><tt class="literal"><span class="pre">iterator_facade</span></tt> Core Operations</p>
|
<p class="topic-title first"><tt class="literal"><span class="pre">iterator_facade</span></tt> Core Operations</p>
|
||||||
<table border class="table">
|
<table border="1" class="table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col width="21%" />
|
<col width="21%" />
|
||||||
<col width="23%" />
|
<col width="23%" />
|
||||||
@ -1089,7 +1090,7 @@ iterator! For a working example of its use, see <a class="reference" href="../e
|
|||||||
<div class="section" id="a-constant-node-iterator">
|
<div class="section" id="a-constant-node-iterator">
|
||||||
<h2><a class="toc-backref" href="#id42" name="a-constant-node-iterator">A constant <tt class="literal"><span class="pre">node_iterator</span></tt></a></h2>
|
<h2><a class="toc-backref" href="#id42" name="a-constant-node-iterator">A constant <tt class="literal"><span class="pre">node_iterator</span></tt></a></h2>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<p class="sidebar-title">Constant and Mutable iterators</p>
|
<p class="sidebar-title first">Constant and Mutable iterators</p>
|
||||||
<p>The term <strong>mutable iterator</strong> means an iterator through which
|
<p>The term <strong>mutable iterator</strong> means an iterator through which
|
||||||
the object it references (its "referent") can be modified. A
|
the object it references (its "referent") can be modified. A
|
||||||
<strong>constant iterator</strong> is one which doesn't allow modification of
|
<strong>constant iterator</strong> is one which doesn't allow modification of
|
||||||
@ -1139,7 +1140,7 @@ class const_node_iterator
|
|||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<p class="sidebar-title"><tt class="literal"><span class="pre">const</span></tt> and an iterator's <tt class="literal"><span class="pre">value_type</span></tt></p>
|
<p class="sidebar-title first"><tt class="literal"><span class="pre">const</span></tt> and an iterator's <tt class="literal"><span class="pre">value_type</span></tt></p>
|
||||||
<p>The C++ standard requires an iterator's <tt class="literal"><span class="pre">value_type</span></tt> <em>not</em> be
|
<p>The C++ standard requires an iterator's <tt class="literal"><span class="pre">value_type</span></tt> <em>not</em> be
|
||||||
<tt class="literal"><span class="pre">const</span></tt>-qualified, so <tt class="literal"><span class="pre">iterator_facade</span></tt> strips the
|
<tt class="literal"><span class="pre">const</span></tt>-qualified, so <tt class="literal"><span class="pre">iterator_facade</span></tt> strips the
|
||||||
<tt class="literal"><span class="pre">const</span></tt> from its <tt class="literal"><span class="pre">Value</span></tt> parameter in order to produce the
|
<tt class="literal"><span class="pre">const</span></tt> from its <tt class="literal"><span class="pre">Value</span></tt> parameter in order to produce the
|
||||||
|
Binary file not shown.
@ -32,6 +32,8 @@
|
|||||||
Derived& operator+=(difference_type n);
|
Derived& operator+=(difference_type n);
|
||||||
Derived& operator-=(difference_type n);
|
Derived& operator-=(difference_type n);
|
||||||
Derived operator-(difference_type n) const;
|
Derived operator-(difference_type n) const;
|
||||||
|
protected:
|
||||||
|
typedef iterator_facade iterator_facade\_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Comparison operators
|
// Comparison operators
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -247,10 +247,10 @@ namespace boost
|
|||||||
{
|
{
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
|
|
||||||
|
protected:
|
||||||
typedef typename detail::iterator_adaptor_base<
|
typedef typename detail::iterator_adaptor_base<
|
||||||
Derived, Base, Value, Traversal, Reference, Difference
|
Derived, Base, Value, Traversal, Reference, Difference
|
||||||
>::type super_t;
|
>::type super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iterator_adaptor() {}
|
iterator_adaptor() {}
|
||||||
|
|
||||||
@ -263,6 +263,9 @@ namespace boost
|
|||||||
{ return m_iterator; }
|
{ return m_iterator; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// for convenience in derived classes
|
||||||
|
typedef iterator_adaptor<Derived,Base,Value,Traversal,Reference,Difference> iterator_adaptor_;
|
||||||
|
|
||||||
//
|
//
|
||||||
// lvalue access to the Base object for Derived
|
// lvalue access to the Base object for Derived
|
||||||
//
|
//
|
||||||
|
@ -586,8 +586,6 @@ namespace boost
|
|||||||
//
|
//
|
||||||
// Curiously Recurring Template interface.
|
// Curiously Recurring Template interface.
|
||||||
//
|
//
|
||||||
typedef Derived derived_t;
|
|
||||||
|
|
||||||
Derived& derived()
|
Derived& derived()
|
||||||
{
|
{
|
||||||
return *static_cast<Derived*>(this);
|
return *static_cast<Derived*>(this);
|
||||||
@ -602,6 +600,10 @@ namespace boost
|
|||||||
Value, CategoryOrTraversal, Reference, Difference
|
Value, CategoryOrTraversal, Reference, Difference
|
||||||
> associated_types;
|
> associated_types;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// For use by derived classes
|
||||||
|
typedef iterator_facade<Derived,Value,Reference,Difference> iterator_facade_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename associated_types::value_type value_type;
|
typedef typename associated_types::value_type value_type;
|
||||||
|
Reference in New Issue
Block a user