Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

iterator_range

Description

iterator_range presents a sub-range of its underlying sequence delimited by a pair of iterators.

Header
#include <boost/fusion/view/iterator_range.hpp>
#include <boost/fusion/include/iterator_range.hpp>
Synopsis
template <typename First, typename Last>
struct iterator_range;
Template parameters

Parameter

Description

Default

First

A fusion Iterator

Last

A fusion Iterator

Model of

Notation

IR

An iterator_range type

f

An instance of First

l

An instance of Last

ir, ir2

Instances of iterator_range

Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in the implemented models.

Expression

Semantics

IR(f, l)

Creates an iterator_range given iterators, f and l.

IR(ir)

Copy constructs an iterator_range from another iterator_range, ir.

ir = ir2

Assigns to a iterator_range, ir, from another iterator_range, ir2.

Example
char const* s = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type vec(1, 'x', 3.3, s);

typedef result_of::begin<vector_type>::type A;
typedef result_of::end<vector_type>::type B;
typedef result_of::next<A>::type C;
typedef result_of::prior<B>::type D;

C c(vec);
D d(vec);

iterator_range<C, D> range(c, d);
std::cout << range << std::endl;

PrevUpHomeNext