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_1031)
  7. #define FUSION_BEGIN_IMPL_07162005_1031
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/view/transform_view/transform_view_fwd.hpp>
  10. namespace boost { namespace fusion
  11. {
  12. template <typename First, typename F>
  13. struct transform_view_iterator;
  14. template <typename First1, typename First2, typename F>
  15. struct transform_view_iterator2;
  16. namespace extension
  17. {
  18. template <typename Tag>
  19. struct begin_impl;
  20. // Unary Version
  21. template <>
  22. struct begin_impl<transform_view_tag>
  23. {
  24. template <typename Sequence>
  25. struct apply
  26. {
  27. typedef typename Sequence::first_type first_type;
  28. typedef typename Sequence::transform_type transform_type;
  29. typedef transform_view_iterator<first_type, transform_type> type;
  30. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  31. static type
  32. call(Sequence& s)
  33. {
  34. return type(s.first(), s.f);
  35. }
  36. };
  37. };
  38. // Binary Version
  39. template <>
  40. struct begin_impl<transform_view2_tag>
  41. {
  42. template <typename Sequence>
  43. struct apply
  44. {
  45. typedef typename Sequence::first1_type first1_type;
  46. typedef typename Sequence::first2_type first2_type;
  47. typedef typename Sequence::transform_type transform_type;
  48. typedef transform_view_iterator2<first1_type, first2_type, transform_type> type;
  49. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  50. static type
  51. call(Sequence& s)
  52. {
  53. return type(s.first1(), s.first2(), s.f);
  54. }
  55. };
  56. };
  57. }
  58. }}
  59. #endif