deref_impl.hpp 2.3 KB

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