/Src/Dependencies/Boost/boost/fusion/sequence/intrinsic/at.hpp

http://hadesmem.googlecode.com/ · C++ Header · 106 lines · 82 code · 17 blank · 7 comment · 0 complexity · ad1c70b2cba478702d760a8f116c9c8c MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2006 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_AT_05042005_0722)
  7. #define FUSION_AT_05042005_0722
  8. #include <boost/mpl/int.hpp>
  9. #include <boost/type_traits/is_const.hpp>
  10. #include <boost/fusion/support/tag_of.hpp>
  11. #include <boost/fusion/support/detail/access.hpp>
  12. namespace boost { namespace fusion
  13. {
  14. // Special tags:
  15. struct sequence_facade_tag;
  16. struct boost_tuple_tag; // boost::tuples::tuple tag
  17. struct boost_array_tag; // boost::array tag
  18. struct mpl_sequence_tag; // mpl sequence tag
  19. struct std_pair_tag; // std::pair tag
  20. namespace extension
  21. {
  22. template <typename Tag>
  23. struct at_impl
  24. {
  25. template <typename Sequence, typename N>
  26. struct apply;
  27. };
  28. template <>
  29. struct at_impl<sequence_facade_tag>
  30. {
  31. template <typename Sequence, typename N>
  32. struct apply : Sequence::template at<Sequence, N> {};
  33. };
  34. template <>
  35. struct at_impl<boost_tuple_tag>;
  36. template <>
  37. struct at_impl<boost_array_tag>;
  38. template <>
  39. struct at_impl<mpl_sequence_tag>;
  40. template <>
  41. struct at_impl<std_pair_tag>;
  42. }
  43. namespace result_of
  44. {
  45. template <typename Sequence, typename N>
  46. struct at
  47. : extension::at_impl<typename detail::tag_of<Sequence>::type>::
  48. template apply<Sequence, N>
  49. {};
  50. template <typename Sequence, int N>
  51. struct at_c
  52. : at<Sequence, mpl::int_<N> >
  53. {};
  54. }
  55. template <typename N, typename Sequence>
  56. inline typename
  57. lazy_disable_if<
  58. is_const<Sequence>
  59. , result_of::at<Sequence, N>
  60. >::type
  61. at(Sequence& seq)
  62. {
  63. return result_of::at<Sequence, N>::call(seq);
  64. }
  65. template <typename N, typename Sequence>
  66. inline typename result_of::at<Sequence const, N>::type
  67. at(Sequence const& seq)
  68. {
  69. return result_of::at<Sequence const, N>::call(seq);
  70. }
  71. template <int N, typename Sequence>
  72. inline typename
  73. lazy_disable_if<
  74. is_const<Sequence>
  75. , result_of::at_c<Sequence, N>
  76. >::type
  77. at_c(Sequence& seq)
  78. {
  79. return fusion::at<mpl::int_<N> >(seq);
  80. }
  81. template <int N, typename Sequence>
  82. inline typename result_of::at_c<Sequence const, N>::type
  83. at_c(Sequence const& seq)
  84. {
  85. return fusion::at<mpl::int_<N> >(seq);
  86. }
  87. }}
  88. #endif