// (C) Copyright Jens Maurer 2001. Permission to copy, use, // modify, sell and distribute this software is granted provided this // copyright notice appears in all copies. This software is provided // "as is" without express or implied warranty, and with no claim as // to its suitability for any purpose. // // Revision History: // 15 Nov 2001 Jens Maurer // created. #ifndef BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP #define BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP #include #include namespace boost { template class generator_iterator_policies { public: generator_iterator_policies() { } template void initialize(Base& base) { m_value = (*base)(); } // The Iter template argument is necessary for compatibility with a MWCW // bug workaround template void increment(IteratorAdaptor& iter) { m_value = (*iter.base())(); } template const typename Generator::result_type& dereference(const IteratorAdaptor&) const { return m_value; } template bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const { return x.base() == y.base() && x.policies().m_value == y.policies().m_value; } private: typename Generator::result_type m_value; }; template struct generator_iterator_generator { typedef iterator_adaptor, typename Generator::result_type, const typename Generator::result_type&, const typename Generator::result_type*, std::input_iterator_tag, long> type; }; template inline typename generator_iterator_generator::type make_generator_iterator(Generator & gen) { typedef typename generator_iterator_generator::type result_t; return result_t(&gen); } } // namespace boost #endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP