<trclass="field"><thclass="field-name">organizations:</th><tdclass="field-body"><aclass="reference"href="http://www.boost-consulting.com">Boost Consulting</a>, Indiana University <aclass="reference"href="http://www.osl.iu.edu">Open Systems
Lab</a>, University of Hanover <aclass="reference"href="http://www.ive.uni-hannover.de">Institute for Transport
<trclass="field"><thclass="field-name">copyright:</th><tdclass="field-body">Copyright Dave Abrahams, Jeremy Siek, Thomas Witt 2003. All rights reserved</td>
<li><aclass="reference"href="#testing-and-concept-checking"id="id10"name="id10">Testing and Concept Checking</a></li>
</ul>
</li>
<li><aclass="reference"href="#upgrading-from-the-old-boost-iterator-adaptor-library"id="id11"name="id11">Upgrading from the old Boost Iterator Adaptor Library</a></li>
<p>The iterator categories defined in C++98 are extremely limiting
because they bind together two orthogonal concepts: traversal and
element access. For example, because a random access iterator is
required to return a reference (and not a proxy) when dereferenced, it
is impossible to capture the capabilities of
<ttclass="literal"><spanclass="pre">vector<bool>::iterator</span></tt> using the C++98 categories. The infamous
"<ttclass="literal"><spanclass="pre">vector<bool></span></tt> is not a container, and its iterators aren't random
access iterators", debacle about which Herb Sutter wrote two papers
for the standards comittee (<aclass="reference"href="http://www.gotw.ca/publications/N1185.pdf">n1185</a> and <aclass="reference"href="http://www.gotw.ca/publications/N1211.pdf">n1211</a>), and a <aclass="reference"href="http://www.gotw.ca/gotw/050.htm">Guru of the
Week</a>. New-style iterators go well beyond patching up
<ttclass="literal"><spanclass="pre">vector<bool></span></tt>, though. There are lots of other iterators already
in use which can't be adequately represented by the existing concepts.
For details about the new iterator concepts, see our</p>
<blockquote>
<aclass="reference"href="new-iter-concepts.html">Standard Proposal For New-Style Iterators</a></blockquote>
<h1><aclass="toc-backref"href="#id6"name="iterator-facade-and-adaptor">Iterator Facade and Adaptor</a></h1>
<p>Writing standard-conforming iterators is tricky. In order to ease the
implementation of new iterators, the iterator library provides the
<aclass="reference"href="iterator_facade.html"><ttclass="literal"><spanclass="pre">iterator_facade</span></tt></a> class template, which implements many useful
defaults and compile-time checks designed to help the author iterator
ensure that his iterator is correct. It is common to define a new
iterator which behaves like another iterator, but modifies some aspect
of its behavior. For that purpose, the library supplies the
<aclass="reference"href="iterator_adaptor.html"><ttclass="literal"><spanclass="pre">iterator_adaptor</span></tt></a> class template, which is specially designed to
take advantage of as much of the underlying iterator's behavior as
possible.</p>
<p>Both <aclass="reference"href="iterator_facade.html"><ttclass="literal"><spanclass="pre">iterator_facade</span></tt></a> and <aclass="reference"href="iterator_adaptor.html"><ttclass="literal"><spanclass="pre">iterator_adaptor</span></tt></a> as well as many of
the <aclass="reference"href="#specialized-adaptors">specialized adaptors</a> mentioned below have been proposed for
standardization; see our</p>
<blockquote>
<aclass="reference"href="facade-and-adaptor.html">Standard Proposal For Iterator Facade and Adaptor</a></blockquote>
<p>The iterator library supplies a useful suite of standard-conforming
iterator templates based on the Boost <aclass="reference"href="#iterator-facade-and-adaptor">iterator facade and adaptor</a>.</p>
<ulclass="simple">
<li><aclass="reference"href="counting_iterator.html"><ttclass="literal"><spanclass="pre">counting_iterator</span></tt></a>: an iterator over a sequence of consecutive values.
Implements a "lazy sequence"</li>
<li><aclass="reference"href="filter_iterator.html"><ttclass="literal"><spanclass="pre">filter_iterator</span></tt></a>: an iterator over the subset of elements of some
sequence which satisfy a given predicate</li>
<li><aclass="reference"href="indirect_iterator.html"><ttclass="literal"><spanclass="pre">indirect_iterator</span></tt></a>: an iterator over the objects <em>pointed-to</em> by the
elements of some sequence.</li>
<li><aclass="reference"href="permutation_iterator.html"><ttclass="literal"><spanclass="pre">permutation_iterator</span></tt></a>: an iterator over the elements of some random-access
sequence, rearranged according to some sequence of integer indices.</li>
<li><aclass="reference"href="reverse_iterator.html"><ttclass="literal"><spanclass="pre">reverse_iterator</span></tt></a>: an iterator which traverses the elements of some
bidirectional sequence in reverse. Corrects many of the
shortcomings of C++98's <ttclass="literal"><spanclass="pre">std::reverse_iterator</span></tt>.</li>
<li><aclass="reference"href="transform_iterator.html"><ttclass="literal"><spanclass="pre">transform_iterator</span></tt></a>: an iterator over elements which are the result of
applying some functional transformation to the elements of an
underlying sequence. This component also replaces the old
<li><aclass="reference"href="iterator_traits.html"><ttclass="literal"><spanclass="pre">iterator_traits.hpp</span></tt></a>: Provides <aclass="reference"href="../../mpl/doc/index.html">MPL</a>-compatible metafunctions which
retrieve an iterator's traits. Also corrects for the deficiencies
of broken implementations of <ttclass="literal"><spanclass="pre">std::iterator_traits</span></tt>.</li>
<li><aclass="reference"href="interoperable.html"><ttclass="literal"><spanclass="pre">interoperable.hpp</span></tt></a>: Provides an <aclass="reference"href="../../mpl/doc/index.html">MPL</a>-compatible metafunction for
<h1><aclass="toc-backref"href="#id11"name="upgrading-from-the-old-boost-iterator-adaptor-library">Upgrading from the old Boost Iterator Adaptor Library</a></h1>
<p>Turn your policy class into the body of the iterator</p>
<p>Use transform_iterator with a true reference type for