Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:09

0001 /* boost random/detail/iterator_mixin.hpp header file
0002  *
0003  * Copyright Jens Maurer 2000-2001
0004  * Distributed under the Boost Software License, Version 1.0. (See
0005  * accompanying file LICENSE_1_0.txt or copy at
0006  * http://www.boost.org/LICENSE_1_0.txt)
0007  *
0008  * See http://www.boost.org for most recent version including documentation.
0009  *
0010  * Revision history
0011  */
0012 
0013 #ifndef BOOST_ITERATOR_MIXIN_HPP
0014 #define BOOST_ITERATOR_MIXIN_HPP
0015 
0016 #include <boost/operators.hpp>
0017 
0018 namespace boost {
0019 
0020 // must be in boost namespace, otherwise the inline friend trick fails
0021 template<class Generator, class ResultType>
0022 class generator_iterator_mixin_adapter
0023   : incrementable<Generator>, equality_comparable<Generator>
0024 {
0025 public:
0026   typedef std::input_iterator_tag iterator_category;
0027   typedef ResultType value_type;
0028   typedef std::ptrdiff_t difference_type;
0029   typedef const value_type * pointer;
0030   typedef const value_type & reference;
0031   Generator& operator++() { v = cast()(); return cast(); }
0032   const value_type& operator*() const { return v; }
0033 
0034 protected:
0035   // instantiate from derived classes only
0036   generator_iterator_mixin_adapter() { }
0037   void iterator_init() { operator++(); }
0038 private:
0039   Generator & cast() { return static_cast<Generator&>(*this); }
0040   value_type v;
0041 };
0042 
0043 } // namespace boost
0044 
0045 #endif // BOOST_ITERATOR_MIXIN_HPP