repetitive_view_iterator.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifdef _MSC_VER
  19. # pragma warning(push)
  20. # pragma warning(disable: 4512) // assignment operator could not be generated.
  21. #endif
  22. namespace boost { namespace fusion
  23. {
  24. struct repetitive_view_iterator_tag;
  25. template<typename Sequence, typename Pos =
  26. typename result_of::begin<Sequence>::type>
  27. struct repetitive_view_iterator
  28. : iterator_base< repetitive_view_iterator<Sequence,Pos> >
  29. {
  30. typedef repetitive_view_iterator_tag fusion_tag;
  31. typedef Sequence sequence_type;
  32. typedef typename convert_iterator<Pos>::type pos_type;
  33. typedef typename convert_iterator<typename result_of::begin<Sequence>::type>::type first_type;
  34. typedef typename convert_iterator<typename result_of::end<Sequence>::type>::type end_type;
  35. typedef single_pass_traversal_tag category;
  36. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  37. explicit repetitive_view_iterator(Sequence& in_seq)
  38. : seq(in_seq), pos(begin(in_seq)) {}
  39. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  40. repetitive_view_iterator(Sequence& in_seq, pos_type const& in_pos)
  41. : seq(in_seq), pos(in_pos) {}
  42. Sequence& seq;
  43. pos_type pos;
  44. };
  45. }}
  46. #ifdef _MSC_VER
  47. # pragma warning(pop)
  48. #endif
  49. #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
  50. namespace std
  51. {
  52. template <typename Sequence, typename Pos>
  53. struct iterator_traits< ::boost::fusion::repetitive_view_iterator<Sequence, Pos> >
  54. { };
  55. }
  56. #endif
  57. #endif