next_impl.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2018 Kohei Takahashi
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(FUSION_NEXT_IMPL_06052005_0900)
  8. #define FUSION_NEXT_IMPL_06052005_0900
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/iterator/next.hpp>
  11. #include <boost/fusion/iterator/equal_to.hpp>
  12. #include <boost/mpl/eval_if.hpp>
  13. #include <boost/mpl/identity.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. struct filter_view_iterator_tag;
  17. template <typename Category, typename First, typename Last, typename Pred>
  18. struct filter_iterator;
  19. namespace extension
  20. {
  21. template <typename Tag>
  22. struct next_impl;
  23. template <>
  24. struct next_impl<filter_view_iterator_tag>
  25. {
  26. template <typename Iterator>
  27. struct apply
  28. {
  29. typedef typename Iterator::first_type first_type;
  30. typedef typename Iterator::last_type last_type;
  31. typedef typename Iterator::pred_type pred_type;
  32. typedef typename Iterator::category category;
  33. typedef typename
  34. mpl::eval_if<
  35. result_of::equal_to<first_type, last_type>
  36. , mpl::identity<last_type>
  37. , result_of::next<first_type>
  38. >::type
  39. next_type;
  40. typedef filter_iterator<category, next_type, last_type, pred_type> type;
  41. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  42. static type
  43. call(Iterator const& i)
  44. {
  45. return type(fusion::next(i.first));
  46. }
  47. };
  48. };
  49. }
  50. }}
  51. #endif