next.hpp 1.7 KB

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