...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
If you have been using the old Boost Iterator Adaptor library to implement
iterators, you probably wrote a Policies
class which 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 type
generator to build the iterator_adaptor
specialization you needed; in the new library 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 use of the Curiously Recurring Template Pattern (CRTP)
[Cop95]_, you can now define the iterator class yourself and acquire functionality
through inheritance from iterator_facade
or iterator_adaptor
. As a result,
you also get much finer control over how your iterator works: you can add additional
constructors, or even override the iterator functionality provided by the library.
If you're looking for the old projection_iterator
component, its functionality has been merged into transform_iterator:
as long as the function object's result_type
(or the Reference
template
argument, if explicitly specified) is a true reference type, transform_iterator
will behave like projection_iterator
used to.