next.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_05042005_1101)
  7. #define FUSION_NEXT_05042005_1101
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/tag_of.hpp>
  10. namespace boost { namespace fusion
  11. {
  12. // Special tags:
  13. struct iterator_facade_tag; // iterator facade tag
  14. struct boost_array_iterator_tag; // boost::array iterator tag
  15. struct mpl_iterator_tag; // mpl sequence iterator tag
  16. struct std_pair_iterator_tag; // std::pair iterator tag
  17. namespace extension
  18. {
  19. template <typename Tag>
  20. struct next_impl
  21. {
  22. template <typename Iterator>
  23. struct apply {};
  24. };
  25. template <>
  26. struct next_impl<iterator_facade_tag>
  27. {
  28. template <typename Iterator>
  29. struct apply : Iterator::template next<Iterator> {};
  30. };
  31. template <>
  32. struct next_impl<boost_array_iterator_tag>;
  33. template <>
  34. struct next_impl<mpl_iterator_tag>;
  35. template <>
  36. struct next_impl<std_pair_iterator_tag>;
  37. }
  38. namespace result_of
  39. {
  40. template <typename Iterator>
  41. struct next
  42. : extension::next_impl<typename detail::tag_of<Iterator>::type>::
  43. template apply<Iterator>
  44. {};
  45. }
  46. template <typename Iterator>
  47. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  48. inline typename result_of::next<Iterator>::type const
  49. next(Iterator const& i)
  50. {
  51. return result_of::next<Iterator>::call(i);
  52. }
  53. }}
  54. #endif