prior_impl.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2005-2006 Dan Marsden
  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_PREV_IMPL_13122005_2110)
  8. #define FUSION_PREV_IMPL_13122005_2110
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/iterator/prior.hpp>
  11. namespace boost { namespace fusion
  12. {
  13. struct transform_view_iterator_tag;
  14. struct transform_view_iterator2_tag;
  15. template<typename First, typename F>
  16. struct transform_view_iterator;
  17. template <typename First1, typename First2, typename F>
  18. struct transform_view_iterator2;
  19. namespace extension
  20. {
  21. template<typename Tag>
  22. struct prior_impl;
  23. // Unary Version
  24. template<>
  25. struct prior_impl<transform_view_iterator_tag>
  26. {
  27. template<typename Iterator>
  28. struct apply
  29. {
  30. typedef typename Iterator::first_type first_type;
  31. typedef typename result_of::prior<first_type>::type prior_type;
  32. typedef typename Iterator::transform_type transform_type;
  33. typedef transform_view_iterator<prior_type, transform_type> type;
  34. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  35. static type
  36. call(Iterator const& i)
  37. {
  38. return type(fusion::prior(i.first), i.f);
  39. }
  40. };
  41. };
  42. // Binary Version
  43. template<>
  44. struct prior_impl<transform_view_iterator2_tag>
  45. {
  46. template<typename Iterator>
  47. struct apply
  48. {
  49. typedef typename Iterator::first1_type first1_type;
  50. typedef typename Iterator::first2_type first2_type;
  51. typedef typename result_of::prior<first1_type>::type prior1_type;
  52. typedef typename result_of::prior<first2_type>::type prior2_type;
  53. typedef typename Iterator::transform_type transform_type;
  54. typedef transform_view_iterator2<prior1_type, prior2_type, transform_type> type;
  55. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  56. static type
  57. call(Iterator const& i)
  58. {
  59. return type(fusion::prior(i.first1), fusion::prior(i.first2), i.f);
  60. }
  61. };
  62. };
  63. }
  64. }}
  65. #endif