repetitive_view_iterator.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*=============================================================================
  2. Copyright (c) 2007 Tobias Schwinger
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_FUSION_REPETITIVE_VIEW_ITERATOR_HPP_INCLUDED
  7. #define BOOST_FUSION_REPETITIVE_VIEW_ITERATOR_HPP_INCLUDED
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/iterator_base.hpp>
  10. #include <boost/fusion/support/category_of.hpp>
  11. #include <boost/fusion/iterator/mpl/convert_iterator.hpp>
  12. #include <boost/fusion/adapted/mpl/mpl_iterator.hpp>
  13. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  14. #include <boost/fusion/sequence/intrinsic/end.hpp>
  15. #include <boost/fusion/view/repetitive_view/detail/deref_impl.hpp>
  16. #include <boost/fusion/view/repetitive_view/detail/next_impl.hpp>
  17. #include <boost/fusion/view/repetitive_view/detail/value_of_impl.hpp>
  18. namespace boost { namespace fusion
  19. {
  20. struct repetitive_view_iterator_tag;
  21. template<typename Sequence, typename Pos =
  22. typename result_of::begin<Sequence>::type>
  23. struct repetitive_view_iterator
  24. : iterator_base< repetitive_view_iterator<Sequence,Pos> >
  25. {
  26. typedef repetitive_view_iterator_tag fusion_tag;
  27. typedef Sequence sequence_type;
  28. typedef typename convert_iterator<Pos>::type pos_type;
  29. typedef typename convert_iterator<typename result_of::begin<Sequence>::type>::type first_type;
  30. typedef typename convert_iterator<typename result_of::end<Sequence>::type>::type end_type;
  31. typedef single_pass_traversal_tag category;
  32. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  33. explicit repetitive_view_iterator(Sequence& in_seq)
  34. : seq(in_seq), pos(begin(in_seq)) {}
  35. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  36. repetitive_view_iterator(Sequence& in_seq, pos_type const& in_pos)
  37. : seq(in_seq), pos(in_pos) {}
  38. Sequence& seq;
  39. pos_type pos;
  40. private:
  41. // silence MSVC warning C4512: assignment operator could not be generated
  42. repetitive_view_iterator& operator= (repetitive_view_iterator const&);
  43. };
  44. }}
  45. #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
  46. namespace std
  47. {
  48. template <typename Sequence, typename Pos>
  49. struct iterator_traits< ::boost::fusion::repetitive_view_iterator<Sequence, Pos> >
  50. { };
  51. }
  52. #endif
  53. #endif