begin_impl.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_BEGIN_IMPL_07162005_0115)
  7. #define FUSION_BEGIN_IMPL_07162005_0115
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/iterator/equal_to.hpp>
  10. #include <boost/mpl/if.hpp>
  11. namespace boost { namespace fusion
  12. {
  13. struct joint_view_tag;
  14. template <typename Category, typename First, typename Last, typename Concat>
  15. struct joint_view_iterator;
  16. namespace extension
  17. {
  18. template <typename Tag>
  19. struct begin_impl;
  20. template <>
  21. struct begin_impl<joint_view_tag>
  22. {
  23. template <typename Sequence>
  24. struct apply
  25. {
  26. typedef typename Sequence::first_type first_type;
  27. typedef typename Sequence::last_type last_type;
  28. typedef typename Sequence::concat_type concat_type;
  29. typedef typename Sequence::category category;
  30. typedef result_of::equal_to<first_type, last_type> equal_to;
  31. typedef typename
  32. mpl::if_<
  33. equal_to
  34. , concat_type
  35. , joint_view_iterator<category, first_type, last_type, concat_type>
  36. >::type
  37. type;
  38. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  39. static type
  40. call(Sequence& s, mpl::true_)
  41. {
  42. return s.concat();
  43. }
  44. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  45. static type
  46. call(Sequence& s, mpl::false_)
  47. {
  48. return type(s.first(), s.concat());
  49. }
  50. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  51. static type
  52. call(Sequence& s)
  53. {
  54. return call(s, equal_to());
  55. }
  56. };
  57. };
  58. }
  59. }}
  60. #endif