1 /* boost random/detail/iterator_mixin.hpp header file
\r
3 * Copyright Jens Maurer 2000-2001
\r
4 * Distributed under the Boost Software License, Version 1.0. (See
\r
5 * accompanying file LICENSE_1_0.txt or copy at
\r
6 * http://www.boost.org/LICENSE_1_0.txt)
\r
8 * See http://www.boost.org for most recent version including documentation.
\r
13 #ifndef BOOST_ITERATOR_MIXIN_HPP
\r
14 #define BOOST_ITERATOR_MIXIN_HPP
\r
16 #include <boost/operators.hpp>
\r
20 // must be in boost namespace, otherwise the inline friend trick fails
\r
21 template<class Generator, class ResultType>
\r
22 class generator_iterator_mixin_adapter
\r
23 : incrementable<Generator>, equality_comparable<Generator>
\r
26 typedef std::input_iterator_tag iterator_category;
\r
27 typedef ResultType value_type;
\r
28 typedef std::ptrdiff_t difference_type;
\r
29 typedef const value_type * pointer;
\r
30 typedef const value_type & reference;
\r
31 Generator& operator++() { v = cast()(); return cast(); }
\r
32 const value_type& operator*() const { return v; }
\r
35 // instantiate from derived classes only
\r
36 generator_iterator_mixin_adapter() { }
\r
37 void iterator_init() { operator++(); }
\r
39 Generator & cast() { return static_cast<Generator&>(*this); }
\r
43 } // namespace boost
\r
45 #endif // BOOST_ITERATOR_MIXIN_HPP
\r