value_at_impl.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 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_VALUE_AT_IMPL_20060124_2129)
  8. #define FUSION_VALUE_AT_IMPL_20060124_2129
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/container/vector/convert.hpp>
  11. #include <boost/fusion/algorithm/transformation/transform.hpp>
  12. #include <boost/fusion/sequence/intrinsic/value_at.hpp>
  13. #include <boost/type_traits/remove_reference.hpp>
  14. #include <boost/fusion/support/unused.hpp>
  15. #include <boost/mpl/eval_if.hpp>
  16. #include <boost/mpl/identity.hpp>
  17. #include <boost/type_traits/is_same.hpp>
  18. #include <boost/config.hpp>
  19. namespace boost { namespace fusion {
  20. struct zip_view_tag;
  21. namespace detail
  22. {
  23. template<typename N>
  24. struct poly_value_at
  25. {
  26. template<typename T>
  27. struct result;
  28. template<typename N1, typename Seq>
  29. struct result<poly_value_at<N1>(Seq)>
  30. : mpl::eval_if<is_same<Seq, unused_type const&>,
  31. mpl::identity<unused_type>,
  32. result_of::value_at<typename remove_reference<Seq>::type, N> >
  33. {};
  34. // never called, but needed for decltype-based result_of (C++0x)
  35. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  36. template<typename Seq>
  37. BOOST_FUSION_GPU_ENABLED
  38. typename result<poly_value_at(Seq)>::type
  39. operator()(Seq&&) const;
  40. #endif
  41. };
  42. }
  43. namespace extension
  44. {
  45. template<typename Tag>
  46. struct value_at_impl;
  47. template<>
  48. struct value_at_impl<zip_view_tag>
  49. {
  50. template<typename Sequence, typename N>
  51. struct apply
  52. {
  53. typedef typename result_of::transform<
  54. typename Sequence::sequences,
  55. detail::poly_value_at<N> >::type values;
  56. typedef typename result_of::as_vector<values>::type type;
  57. };
  58. };
  59. }
  60. }}
  61. #endif