next_impl.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2005 Eric Niebler
  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_07172005_0836)
  8. #define FUSION_NEXT_IMPL_07172005_0836
  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. #include <boost/type_traits/is_const.hpp>
  15. #include <boost/type_traits/add_const.hpp>
  16. namespace boost { namespace fusion
  17. {
  18. struct cons_iterator_tag;
  19. template <typename Cons>
  20. struct cons_iterator;
  21. namespace extension
  22. {
  23. template <typename Tag>
  24. struct next_impl;
  25. template <>
  26. struct next_impl<cons_iterator_tag>
  27. {
  28. template <typename Iterator>
  29. struct apply
  30. {
  31. typedef typename Iterator::cons_type cons_type;
  32. typedef typename cons_type::cdr_type cdr_type;
  33. typedef cons_iterator<
  34. typename mpl::eval_if<
  35. is_const<cons_type>
  36. , add_const<cdr_type>
  37. , mpl::identity<cdr_type>
  38. >::type>
  39. type;
  40. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  41. static type
  42. call(Iterator const& i)
  43. {
  44. return type(i.cons.cdr);
  45. }
  46. };
  47. };
  48. }
  49. }}
  50. #endif