value_at.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_VALUE_AT_05052005_0229)
  7. #define FUSION_VALUE_AT_05052005_0229
  8. #include <boost/mpl/int.hpp>
  9. #include <boost/fusion/sequence/intrinsic_fwd.hpp>
  10. #include <boost/fusion/support/tag_of.hpp>
  11. namespace boost { namespace fusion
  12. {
  13. // Special tags:
  14. struct sequence_facade_tag;
  15. struct boost_tuple_tag; // boost::tuples::tuple tag
  16. struct boost_array_tag; // boost::array tag
  17. struct mpl_sequence_tag; // mpl sequence tag
  18. struct std_pair_tag; // std::pair tag
  19. namespace extension
  20. {
  21. template <typename Tag>
  22. struct value_at_impl
  23. {
  24. template <typename Sequence, typename N>
  25. struct apply;
  26. };
  27. template <>
  28. struct value_at_impl<sequence_facade_tag>
  29. {
  30. template <typename Sequence, typename N>
  31. struct apply : Sequence::template value_at<Sequence, N> {};
  32. };
  33. template <>
  34. struct value_at_impl<boost_tuple_tag>;
  35. template <>
  36. struct value_at_impl<boost_array_tag>;
  37. template <>
  38. struct value_at_impl<mpl_sequence_tag>;
  39. template <>
  40. struct value_at_impl<std_pair_tag>;
  41. }
  42. namespace result_of
  43. {
  44. template <typename Sequence, typename N>
  45. struct value_at
  46. : extension::value_at_impl<typename detail::tag_of<Sequence>::type>::
  47. template apply<Sequence, N>
  48. {};
  49. template <typename Sequence, int N>
  50. struct value_at_c
  51. : fusion::result_of::value_at<Sequence, mpl::int_<N> >
  52. {};
  53. }
  54. }}
  55. #endif