at_impl.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2005-2006 Dan Marsden
  4. Copyright (c) 2018 Kohei Takahashi
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #if !defined(BOOST_FUSION_AT_IMPL_20061029_1946)
  9. #define BOOST_FUSION_AT_IMPL_20061029_1946
  10. #include <boost/fusion/support/config.hpp>
  11. #include <boost/fusion/sequence/intrinsic/at.hpp>
  12. #include <boost/utility/result_of.hpp>
  13. namespace boost { namespace fusion {
  14. struct transform_view_tag;
  15. struct transform_view2_tag;
  16. namespace extension
  17. {
  18. template<typename Tag>
  19. struct at_impl;
  20. template<>
  21. struct at_impl<transform_view_tag>
  22. {
  23. template<typename Seq, typename N>
  24. struct apply
  25. {
  26. typedef typename Seq::transform_type F;
  27. typedef typename result_of::at<typename Seq::sequence_type, N>::type value_type;
  28. typedef typename boost::result_of<F(value_type)>::type type;
  29. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  30. static type call(Seq& seq)
  31. {
  32. return seq.f(boost::fusion::at<N>(seq.seq));
  33. }
  34. };
  35. };
  36. template<>
  37. struct at_impl<transform_view2_tag>
  38. {
  39. template<typename Seq, typename N>
  40. struct apply
  41. {
  42. typedef typename Seq::transform_type F;
  43. typedef typename result_of::at<typename Seq::sequence1_type, N>::type value1_type;
  44. typedef typename result_of::at<typename Seq::sequence2_type, N>::type value2_type;
  45. typedef typename boost::result_of<F(value1_type, value2_type)>::type type;
  46. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  47. static type call(Seq& seq)
  48. {
  49. return seq.f(boost::fusion::at<N>(seq.seq1), boost::fusion::at<N>(seq.seq2));
  50. }
  51. };
  52. };
  53. }
  54. }}
  55. #endif