2003-07-29 22:25:39 +00:00
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< 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" / >
2006-09-11 22:27:29 +00:00
< meta name = "generator" content = "Docutils 0.4: http://docutils.sourceforge.net/" / >
2003-11-24 05:02:46 +00:00
< title > The Boost.Iterator Library Boost< / title >
2006-09-11 22:27:29 +00:00
< style type = "text/css" >
/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:Date: $Date$
:Revision: $Revision$
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, 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.admonition p.admonition-title, 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.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 }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
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 ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin-left: 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
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.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left {
clear: left }
img.align-right {
clear: right }
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.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
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 {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
tt.docutils {
background-color: #eeeeee }
ul.auto-toc {
list-style-type: none }
< / style >
2003-07-29 22:25:39 +00:00
< / head >
< body >
2004-07-14 12:33:36 +00:00
< div class = "document" id = "the-boost-iterator-library-logo" >
2005-05-20 15:32:55 +00:00
< h1 class = "title" > The Boost.Iterator Library < a class = "reference" href = "../../../index.htm" > < img alt = "Boost" src = "../../../boost.png" / > < / a > < / h1 >
2006-09-11 22:27:29 +00:00
<!-- Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
2005-05-20 15:32:55 +00:00
< hr class = "docutils" / >
< table class = "docutils field-list" frame = "void" rules = "none" >
2003-07-29 22:25:39 +00:00
< col class = "field-name" / >
< col class = "field-body" / >
< tbody valign = "top" >
< tr class = "field" > < th class = "field-name" > Authors:< / th > < td class = "field-body" > David Abrahams, Jeremy Siek, Thomas Witt< / td >
< / tr >
2004-01-18 20:54:59 +00:00
< tr class = "field" > < th class = "field-name" > Contact:< / th > < td class = "field-body" > < a class = "reference" href = "mailto:dave@boost-consulting.com" > dave@ boost-consulting.com< / a > , < a class = "reference" href = "mailto:jsiek@osl.iu.edu" > jsiek@ osl.iu.edu< / a > , < a class = "reference" href = "mailto:witt@styleadvisor.com" > witt@ styleadvisor.com< / a > < / td >
2003-07-29 22:25:39 +00:00
< / tr >
< tr class = "field" > < th class = "field-name" > organizations:< / th > < td class = "field-body" > < a class = "reference" href = "http://www.boost-consulting.com" > Boost Consulting< / a > , Indiana University < a class = "reference" href = "http://www.osl.iu.edu" > Open Systems
2004-01-18 20:54:59 +00:00
Lab< / a > , < a class = "reference" href = "http://www.styleadvisor.com" > Zephyr Associates, Inc.< / a > < / td >
2003-07-29 22:25:39 +00:00
< / tr >
< tr class = "field" > < th class = "field-name" > date:< / th > < td class = "field-body" > $Date$< / td >
< / tr >
2004-11-02 14:31:27 +00:00
< tr class = "field" > < th class = "field-name" > copyright:< / th > < td class = "field-body" > Copyright David Abrahams, Jeremy Siek, Thomas Witt 2003.< / td >
2003-07-29 22:25:39 +00:00
< / tr >
< / tbody >
< / table >
2005-05-20 15:32:55 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2003-07-29 22:25:39 +00:00
< col class = "field-name" / >
< col class = "field-body" / >
< tbody valign = "top" >
2003-08-05 16:36:51 +00:00
< tr class = "field" > < th class = "field-name" > Abstract:< / th > < td class = "field-body" > The Boost Iterator Library contains two parts. The first
2003-09-14 02:17:41 +00:00
is a system of < a class = "reference" href = "../../../more/generic_programming.html#concept" > concepts< / a > which extend the C++ standard
2003-11-24 05:02:46 +00:00
iterator requirements. The second is a framework of
components for building iterators based on these
2003-08-05 16:36:51 +00:00
extended concepts and includes several useful iterator
2003-11-24 05:02:46 +00:00
adaptors. The extended iterator concepts have been
2004-04-29 00:38:46 +00:00
carefully designed so that old-style iterators
2003-11-24 05:02:46 +00:00
can fit in the new concepts and so that new-style
iterators will be compatible with old-style algorithms,
though algorithms may need to be updated if they want to
take full advantage of the new-style iterator
capabilities. Several components of this library have
been accepted into the C++ standard technical report.
The components of the Boost Iterator Library replace the
older Boost Iterator Adaptor Library.< / td >
2003-07-29 22:25:39 +00:00
< / tr >
< / tbody >
< / table >
2006-09-11 22:27:29 +00:00
< div class = "contents topic" >
< p class = "topic-title first" > < a id = "table-of-contents" name = "table-of-contents" > < strong > Table of Contents< / strong > < / a > < / p >
2003-07-29 22:25:39 +00:00
< ul class = "simple" >
2004-02-01 03:58:49 +00:00
< li > < a class = "reference" href = "#new-style-iterators" id = "id22" name = "id22" > New-Style Iterators< / a > < / li >
< li > < a class = "reference" href = "#iterator-facade-and-adaptor" id = "id23" name = "id23" > Iterator Facade and Adaptor< / a > < / li >
< li > < a class = "reference" href = "#specialized-adaptors" id = "id24" name = "id24" > Specialized Adaptors< / a > < / li >
< li > < a class = "reference" href = "#iterator-utilities" id = "id25" name = "id25" > Iterator Utilities< / a > < ul >
< li > < a class = "reference" href = "#traits" id = "id26" name = "id26" > Traits< / a > < / li >
< li > < a class = "reference" href = "#testing-and-concept-checking" id = "id27" name = "id27" > Testing and Concept Checking< / a > < / li >
2003-07-29 22:25:39 +00:00
< / ul >
< / li >
2004-02-01 03:58:49 +00:00
< li > < a class = "reference" href = "#upgrading-from-the-old-boost-iterator-adaptor-library" id = "id28" name = "id28" > Upgrading from the old Boost Iterator Adaptor Library< / a > < / li >
< li > < a class = "reference" href = "#history" id = "id29" name = "id29" > History< / a > < / li >
2003-07-29 22:25:39 +00:00
< / ul >
< / div >
2005-05-20 15:32:55 +00:00
< hr class = "docutils" / >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h1 > < a class = "toc-backref" href = "#id22" id = "new-style-iterators" name = "new-style-iterators" > New-Style Iterators< / a > < / h1 >
2003-07-29 22:25:39 +00:00
< 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
2003-09-14 02:17:41 +00:00
required to return a reference (and not a proxy) when dereferenced,
it is impossible to capture the capabilities of
2005-05-20 15:32:55 +00:00
< tt class = "docutils literal" > < span class = "pre" > vector< bool> ::iterator< / span > < / tt > using the C++98 categories. This is the
infamous " < tt class = "docutils literal" > < span class = "pre" > vector< bool> < / span > < / tt > is not a container, and its iterators
2003-09-14 02:17:41 +00:00
aren't random access iterators" , debacle about which Herb Sutter
wrote two papers for the standards comittee (< a class = "reference" href = "http://www.gotw.ca/publications/N1185.pdf" > n1185< / a > and < a class = "reference" href = "http://www.gotw.ca/publications/N1211.pdf" > n1211< / a > ),
and a < a class = "reference" href = "http://www.gotw.ca/gotw/050.htm" > Guru of the Week< / a > . New-style iterators go well beyond
2005-05-20 15:32:55 +00:00
patching up < tt class = "docutils literal" > < span class = "pre" > vector< bool> < / span > < / tt > , though: there are lots of other
2003-09-14 02:17:41 +00:00
iterators already in use which can't be adequately represented by
the existing concepts. For details about the new iterator
concepts, see our< / p >
2003-07-29 22:25:39 +00:00
< blockquote >
2004-01-27 04:05:33 +00:00
< a class = "reference" href = "new-iter-concepts.html" > Standard Proposal For New-Style Iterators< / a > (< a class = "reference" href = "new-iter-concepts.pdf" > PDF< / a > )< / blockquote >
2003-07-29 22:25:39 +00:00
< / div >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h1 > < a class = "toc-backref" href = "#id23" id = "iterator-facade-and-adaptor" name = "iterator-facade-and-adaptor" > Iterator Facade and Adaptor< / a > < / h1 >
2003-11-24 05:02:46 +00:00
< p > Writing standard-conforming iterators is tricky, but the need comes
up often. In order to ease the implementation of new iterators,
2005-05-20 15:32:55 +00:00
the Boost.Iterator library provides the < tt class = "docutils literal" > < span class = "pre" > iterator_facade< / span > < / tt > class template,
2003-11-24 05:02:46 +00:00
which implements many useful defaults and compile-time checks
2004-01-18 20:54:59 +00:00
designed to help the iterator author ensure that his iterator is
2004-01-10 19:00:48 +00:00
correct.< / p >
< p > It is also common to define a new iterator that is similar to some
underlying iterator or iterator-like type, but that modifies some
aspect of the underlying type's behavior. For that purpose, the
2005-05-20 15:32:55 +00:00
library supplies the < tt class = "docutils literal" > < span class = "pre" > iterator_adaptor< / span > < / tt > class template, which is specially
2004-01-10 19:00:48 +00:00
designed to take advantage of as much of the underlying type's
behavior as possible.< / p >
2004-01-12 15:14:26 +00:00
< p > The documentation for these two classes can be found at the following
web pages:< / p >
< ul class = "simple" >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "iterator_facade.html" > < tt class = "docutils literal" > < span class = "pre" > iterator_facade< / span > < / tt > < / a > (< a class = "reference" href = "iterator_facade.pdf" > PDF< / a > )< / li >
< li > < a class = "reference" href = "iterator_adaptor.html" > < tt class = "docutils literal" > < span class = "pre" > iterator_adaptor< / span > < / tt > < / a > (< a class = "reference" href = "iterator_adaptor.pdf" > PDF< / a > )< / li >
2004-01-12 15:14:26 +00:00
< / ul >
2005-05-20 15:32:55 +00:00
< p > Both < tt class = "docutils literal" > < span class = "pre" > iterator_facade< / span > < / tt > and < tt class = "docutils literal" > < span class = "pre" > iterator_adaptor< / span > < / tt > as well as many of the < a class = "reference" href = "#specialized-adaptors" > specialized
2003-11-24 05:02:46 +00:00
adaptors< / a > mentioned below have been proposed for standardization,
and accepted into the first C++ technical report; see our< / p >
2003-07-29 22:25:39 +00:00
< blockquote >
2004-01-27 04:05:33 +00:00
< a class = "reference" href = "facade-and-adaptor.html" > Standard Proposal For Iterator Facade and Adaptor< / a > (< a class = "reference" href = "facade-and-adaptor.pdf" > PDF< / a > )< / blockquote >
2003-07-29 22:25:39 +00:00
< p > for more details.< / p >
< / div >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h1 > < a class = "toc-backref" href = "#id24" id = "specialized-adaptors" name = "specialized-adaptors" > Specialized Adaptors< / a > < / h1 >
2003-07-29 22:25:39 +00:00
< p > The iterator library supplies a useful suite of standard-conforming
iterator templates based on the Boost < a class = "reference" href = "#iterator-facade-and-adaptor" > iterator facade and adaptor< / a > .< / p >
< ul class = "simple" >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "counting_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > counting_iterator< / span > < / tt > < / a > (< a class = "reference" href = "counting_iterator.pdf" > PDF< / a > ): an iterator over a sequence of consecutive values.
2003-07-29 22:25:39 +00:00
Implements a " lazy sequence" < / li >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "filter_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > filter_iterator< / span > < / tt > < / a > (< a class = "reference" href = "filter_iterator.pdf" > PDF< / a > ): an iterator over the subset of elements of some
2003-07-29 22:25:39 +00:00
sequence which satisfy a given predicate< / li >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "function_output_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > function_output_iterator< / span > < / tt > < / a > (< a class = "reference" href = "function_output_iterator.pdf" > PDF< / a > ): an output iterator wrapping a unary function
2004-02-01 03:58:49 +00:00
object; each time an element is written into the dereferenced
iterator, it is passed as a parameter to the function object.< / li >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "indirect_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > indirect_iterator< / span > < / tt > < / a > (< a class = "reference" href = "indirect_iterator.pdf" > PDF< / a > ): an iterator over the objects < em > pointed-to< / em > by the
2003-07-29 22:25:39 +00:00
elements of some sequence.< / li >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "permutation_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > permutation_iterator< / span > < / tt > < / a > (< a class = "reference" href = "permutation_iterator.pdf" > PDF< / a > ): an iterator over the elements of some random-access
2003-07-29 22:25:39 +00:00
sequence, rearranged according to some sequence of integer indices.< / li >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "reverse_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > reverse_iterator< / span > < / tt > < / a > (< a class = "reference" href = "reverse_iterator.pdf" > PDF< / a > ): an iterator which traverses the elements of some
2003-07-29 22:25:39 +00:00
bidirectional sequence in reverse. Corrects many of the
2005-05-20 15:32:55 +00:00
shortcomings of C++98's < tt class = "docutils literal" > < span class = "pre" > std::reverse_iterator< / span > < / tt > .< / li >
< li > < a class = "reference" href = "../../utility/shared_container_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > shared_container_iterator< / span > < / tt > < / a > : an iterator over elements of a container whose
lifetime is maintained by a < a class = "reference" href = "../../smart_ptr/shared_ptr.htm" > < tt class = "docutils literal" > < span class = "pre" > shared_ptr< / span > < / tt > < / a > stored in the iterator.< / li >
< li > < a class = "reference" href = "transform_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > transform_iterator< / span > < / tt > < / a > (< a class = "reference" href = "transform_iterator.pdf" > PDF< / a > ): an iterator over elements which are the result of
2003-07-29 22:25:39 +00:00
applying some functional transformation to the elements of an
underlying sequence. This component also replaces the old
2005-05-20 15:32:55 +00:00
< tt class = "docutils literal" > < span class = "pre" > projection_iterator_adaptor< / span > < / tt > .< / li >
< li > < a class = "reference" href = "zip_iterator.html" > < tt class = "docutils literal" > < span class = "pre" > zip_iterator< / span > < / tt > < / a > (< a class = "reference" href = "zip_iterator.pdf" > PDF< / a > ): an iterator over tuples of the elements at corresponding
2004-01-19 18:52:48 +00:00
positions of heterogeneous underlying iterators.< / li >
2003-07-29 22:25:39 +00:00
< / ul >
< / div >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h1 > < a class = "toc-backref" href = "#id25" id = "iterator-utilities" name = "iterator-utilities" > Iterator Utilities< / a > < / h1 >
< div class = "section" >
< h2 > < a class = "toc-backref" href = "#id26" id = "traits" name = "traits" > Traits< / a > < / h2 >
2003-07-29 22:25:39 +00:00
< ul class = "simple" >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "pointee.html" > < tt class = "docutils literal" > < span class = "pre" > pointee.hpp< / span > < / tt > < / a > (< a class = "reference" href = "pointee.pdf" > PDF< / a > ): Provides the capability to deduce the referent types
2004-01-13 23:03:18 +00:00
of pointers, smart pointers and iterators in generic code. Used
2005-05-20 15:32:55 +00:00
in < tt class = "docutils literal" > < span class = "pre" > indirect_iterator< / span > < / tt > .< / li >
< li > < a class = "reference" href = "iterator_traits.html" > < tt class = "docutils literal" > < span class = "pre" > iterator_traits.hpp< / span > < / tt > < / a > (< a class = "reference" href = "iterator_traits.pdf" > PDF< / a > ): Provides < a class = "reference" href = "../../mpl/doc/index.html" > MPL< / a > -compatible metafunctions which
2003-07-29 22:25:39 +00:00
retrieve an iterator's traits. Also corrects for the deficiencies
2005-05-20 15:32:55 +00:00
of broken implementations of < tt class = "docutils literal" > < span class = "pre" > std::iterator_traits< / span > < / tt > .< / li >
2003-07-29 22:25:39 +00:00
< / ul >
2004-01-29 05:55:26 +00:00
<!-- * |interoperable|_ (PDF__): Provides an MPL_\ - compatible metafunction for
testing iterator interoperability -->
<!-- comment! __ interoperable.pdf -->
2003-07-29 22:25:39 +00:00
< / div >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h2 > < a class = "toc-backref" href = "#id27" id = "testing-and-concept-checking" name = "testing-and-concept-checking" > Testing and Concept Checking< / a > < / h2 >
2003-07-29 22:25:39 +00:00
< ul class = "simple" >
2005-05-20 15:32:55 +00:00
< li > < a class = "reference" href = "iterator_concepts.html" > < tt class = "docutils literal" > < span class = "pre" > iterator_concepts.hpp< / span > < / tt > < / a > (< a class = "reference" href = "iterator_concepts.pdf" > PDF< / a > ): Concept checking classes for the new iterator concepts.< / li >
< li > < a class = "reference" href = "iterator_archetypes.html" > < tt class = "docutils literal" > < span class = "pre" > iterator_archetypes.hpp< / span > < / tt > < / a > (< a class = "reference" href = "iterator_archetypes.pdf" > PDF< / a > ): Concept archetype classes for the new iterators concepts.< / li >
2003-07-29 22:25:39 +00:00
< / ul >
< / div >
< / div >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h1 > < a class = "toc-backref" href = "#id28" id = "upgrading-from-the-old-boost-iterator-adaptor-library" name = "upgrading-from-the-old-boost-iterator-adaptor-library" > Upgrading from the old Boost Iterator Adaptor Library< / a > < / h1 >
< p id = "upgrading" > If you have been using the old Boost Iterator Adaptor library to
2005-05-20 15:32:55 +00:00
implement iterators, you probably wrote a < tt class = "docutils literal" > < span class = "pre" > Policies< / span > < / tt > class which
2003-11-24 05:02:46 +00:00
captures the core operations of your iterator. In the new library
design, you'll move those same core operations into the body of the
iterator class itself. If you were writing a family of iterators,
you probably wrote a < a class = "reference" href = "../../../more/generic_programming.html#type_generator" > type generator< / a > to build the
2005-05-20 15:32:55 +00:00
< tt class = "docutils literal" > < span class = "pre" > iterator_adaptor< / span > < / tt > specialization you needed; in the new library
2003-11-24 05:02:46 +00:00
design you don't need a type generator (though may want to keep it
around as a compatibility aid for older code) because, due to the
2004-02-01 03:58:49 +00:00
use of the Curiously Recurring Template Pattern (CRTP) < a class = "citation-reference" href = "#cop95" id = "id21" name = "id21" > [Cop95]< / a > ,
2003-11-24 05:02:46 +00:00
you can now define the iterator class yourself and acquire
2005-05-20 15:32:55 +00:00
functionality through inheritance from < tt class = "docutils literal" > < span class = "pre" > iterator_facade< / span > < / tt > or
< tt class = "docutils literal" > < span class = "pre" > iterator_adaptor< / span > < / tt > . As a result, you also get much finer control
2003-11-24 05:02:46 +00:00
over how your iterator works: you can add additional constructors,
or even override the iterator functionality provided by the
library.< / p >
2005-05-20 15:32:55 +00:00
< p > If you're looking for the old < tt class = "docutils literal" > < span class = "pre" > projection_iterator< / span > < / tt > component,
its functionality has been merged into < tt class = "docutils literal" > < span class = "pre" > transform_iterator< / span > < / tt > : as
long as the function object's < tt class = "docutils literal" > < span class = "pre" > result_type< / span > < / tt > (or the < tt class = "docutils literal" > < span class = "pre" > Reference< / span > < / tt >
2003-11-24 05:02:46 +00:00
template argument, if explicitly specified) is a true reference
2005-05-20 15:32:55 +00:00
type, < tt class = "docutils literal" > < span class = "pre" > transform_iterator< / span > < / tt > will behave like
< tt class = "docutils literal" > < span class = "pre" > projection_iterator< / span > < / tt > used to.< / p >
2003-07-29 22:25:39 +00:00
< / div >
2006-09-11 22:27:29 +00:00
< div class = "section" >
< h1 > < a class = "toc-backref" href = "#id29" id = "history" name = "history" > History< / a > < / h1 >
2003-07-29 22:25:39 +00:00
< p > In 2000 Dave Abrahams was writing an iterator for a container of
pointers, which would access the pointed-to elements when
dereferenced. Naturally, being a library writer, he decided to
generalize the idea and the Boost Iterator Adaptor library was born.
Dave was inspired by some writings of Andrei Alexandrescu and chose a
policy based design (though he probably didn't capture Andrei's idea
very well - there was only one policy class for all the iterator's
orthogonal properties). Soon Jeremy Siek realized he would need the
library and they worked together to produce a " Boostified" version,
which was reviewed and accepted into the library. They wrote a paper
and made several important revisions of the code.< / p >
< p > Eventually, several shortcomings of the older library began to make
2003-11-24 05:02:46 +00:00
the need for a rewrite apparent. Dave and Jeremy started working
at the Santa Cruz C++ committee meeting in 2002, and had quickly
generated a working prototype. At the urging of Mat Marcus, they
decided to use the GenVoca/CRTP pattern approach, and moved the
policies into the iterator class itself. Thomas Witt expressed
interest and became the voice of strict compile-time checking for
the project, adding uses of the SFINAE technique to eliminate false
converting constructors and operators from the overload set. He
2005-05-20 15:32:55 +00:00
also recognized the need for a separate < tt class = "docutils literal" > < span class = "pre" > iterator_facade< / span > < / tt > , and
factored it out of < tt class = "docutils literal" > < span class = "pre" > iterator_adaptor< / span > < / tt > . Finally, after a
2003-11-24 05:02:46 +00:00
near-complete rewrite of the prototype, they came up with the
library you see today.< / p >
2005-05-20 15:32:55 +00:00
< table class = "docutils citation" frame = "void" id = "cop95" rules = "none" >
2003-11-24 05:02:46 +00:00
< colgroup > < col class = "label" / > < col / > < / colgroup >
< tbody valign = "top" >
2004-02-01 03:58:49 +00:00
< tr > < td class = "label" > < a class = "fn-backref" href = "#id21" name = "cop95" > [Cop95]< / a > < / td > < td > [Coplien, 1995] Coplien, J., Curiously Recurring Template
2003-11-24 05:02:46 +00:00
Patterns, C++ Report, February 1995, pp. 24-27.< / td > < / tr >
< / tbody >
< / table >
2003-07-29 22:25:39 +00:00
<!-- LocalWords: Abrahams Siek Witt const bool Sutter's WG int UL LI href Lvalue
LocalWords: ReadableIterator WritableIterator SwappableIterator cv pre iter
LocalWords: ConstantLvalueIterator MutableLvalueIterator CopyConstructible TR
LocalWords: ForwardTraversalIterator BidirectionalTraversalIterator lvalue
LocalWords: RandomAccessTraversalIterator dereferenceable Incrementable tmp
LocalWords: incrementable xxx min prev inplace png oldeqnew AccessTag struct
LocalWords: TraversalTag typename lvalues DWA Hmm JGS -->
< / div >
< / div >
< / body >
< / html >