diff --git a/generator_iterator.htm b/generator_iterator.htm index fd3e3fc..c81d3d1 100644 --- a/generator_iterator.htm +++ b/generator_iterator.htm @@ -1,33 +1,37 @@ - +
--The generator iterator adaptor makes it easier to create custom input -iterators from 0-ary functions and function objects. The adaptor -takes a -Generator -and creates a model of -Input Iterator. -Each increment retrieves an item from the generator and makes it -available to be retrieved by dereferencing. The motivation for this -iterator is that some concepts can be more naturally expressed as a -generator, while most STL algorithms expect an iterator. An example -is the Random Number library. +
Defined in header boost/generator_iterator.hpp
--++The generator iterator adaptor makes it easier to create custom input + iterators from 0-ary functions and function objects. The adaptor takes a + Generator and + creates a model of Input Iterator. Each + increment retrieves an item from the generator and makes it available to be + retrieved by dereferencing. The motivation for this iterator is that some + concepts can be more naturally expressed as a generator, while most STL + algorithms expect an iterator. An example is the Random Number library.
+ +Synopsis
+ +++namespace boost { template <class Generator> class generator_iterator_policies; @@ -40,21 +44,19 @@ namespace boost { make_generator_iterator(Generator & gen); }-
-template <class Generator> +The class generator_iterator_generator is a helper class whose purpose + is to construct a generator iterator type. The template parameter for this + class is the Generator function object type that is being wrapped. The + generator iterator adaptor only holds a reference (or pointer) to the + function object, therefore the function object must outlive the generator + iterator adaptor constructed from it.
++template <class Generator> class generator_iterator_generator { public: @@ -62,65 +64,65 @@ public: }+Template Parameters
-Template Parameters
+
Parameter | -
---|
Parameter | -Description | -Description | + -
---|---|
Generator - | The generator (0-ary function object) type being -wrapped. The return type of the function must be defined as -Generator::result_type. The function object must be a model -of -Generator. - | -
The generator iterator class is a model of Input Iterator.
-The generator iterator implements the member functions and operators
+ required of the Input Iterator
+ concept.
-++The + Generator Iterator Object Generator
+ +The make_generator_iterator() function provides a convenient + way to create generator iterator objects. The function saves the user the + trouble of explicitly writing out the iterator types.
+ +++template <class Generator> typename generator_iterator_generator<Generator>::type make_generator_iterator(Generator & gen);-
The following program shows how generator_iterator
+ transforms a generator into an input iterator.
generator_iterator
-transforms a generator into an input iterator.
-
--+-#include <iostream> -#include <boost/generator_iterator.hpp> ++++#include <iostream> +#include <boost/generator_iterator.hpp> class my_generator { @@ -140,11 +142,22 @@ int main() std::cout << *it << std::endl; }-
Revised + 05 December, 2006
+Copyright © 2001 Jens Maurer
+ +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)