next_impl.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  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. #if !defined(FUSION_NEXT_IMPL_07162005_0136)
  7. #define FUSION_NEXT_IMPL_07162005_0136
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/iterator/next.hpp>
  10. #include <boost/fusion/iterator/equal_to.hpp>
  11. #include <boost/mpl/if.hpp>
  12. namespace boost { namespace fusion
  13. {
  14. struct joint_view_iterator_tag;
  15. template <typename Category, typename First, typename Last, typename Concat>
  16. struct joint_view_iterator;
  17. namespace extension
  18. {
  19. template <typename Tag>
  20. struct next_impl;
  21. template <>
  22. struct next_impl<joint_view_iterator_tag>
  23. {
  24. template <typename Iterator>
  25. struct apply
  26. {
  27. typedef typename Iterator::first_type first_type;
  28. typedef typename Iterator::last_type last_type;
  29. typedef typename Iterator::concat_type concat_type;
  30. typedef typename Iterator::category category;
  31. typedef typename result_of::next<first_type>::type next_type;
  32. typedef result_of::equal_to<next_type, last_type> equal_to;
  33. typedef typename
  34. mpl::if_<
  35. equal_to
  36. , concat_type
  37. , joint_view_iterator<category, next_type, last_type, concat_type>
  38. >::type
  39. type;
  40. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  41. static type
  42. call(Iterator const& i, mpl::true_)
  43. {
  44. return i.concat;
  45. }
  46. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  47. static type
  48. call(Iterator const& i, mpl::false_)
  49. {
  50. return type(fusion::next(i.first), i.concat);
  51. }
  52. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  53. static type
  54. call(Iterator const& i)
  55. {
  56. return call(i, equal_to());
  57. }
  58. };
  59. };
  60. }
  61. }}
  62. #endif