functor2iterator.hpp 883 B

12345678910111213141516171819202122232425262728293031323334
  1. // (C) Copyright John Maddock 2005.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_TR1_FUNCTOR_IT_HPP_INCLUDED
  6. # define BOOST_TR1_FUNCTOR_IT_HPP_INCLUDED
  7. # include <boost/iterator/iterator_facade.hpp>
  8. namespace boost{ namespace tr1_details{
  9. template <class Func, class R>
  10. struct functor2iterator : boost::iterator_facade<functor2iterator<Func,R>, const R, std::input_iterator_tag>
  11. {
  12. functor2iterator() : m_func(0){}
  13. functor2iterator(Func& f)
  14. : m_func(&f)
  15. {
  16. m_val = (*m_func)();
  17. }
  18. const R& dereference()const
  19. { return m_val; }
  20. void increment(){ m_val = (*m_func)(); }
  21. bool equal(const functor2iterator&)const
  22. { return false; }
  23. private:
  24. Func* m_func;
  25. R m_val;
  26. };
  27. } }
  28. #endif