tuple.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // tuple.hpp - Boost Tuple Library --------------------------------------
  2. // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. // For more information, see http://www.boost.org
  8. // -----------------------------------------------------------------
  9. #ifndef BOOST_TUPLE_HPP
  10. #define BOOST_TUPLE_HPP
  11. #if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730
  12. // Work around a compiler bug.
  13. // boost::python::tuple has to be seen by the compiler before the
  14. // boost::tuple class template.
  15. namespace boost { namespace python { class tuple; }}
  16. #endif
  17. #include <boost/config.hpp>
  18. #include <boost/static_assert.hpp>
  19. // other compilers
  20. #include <boost/ref.hpp>
  21. #include <boost/tuple/detail/tuple_basic.hpp>
  22. namespace boost {
  23. using tuples::tuple;
  24. using tuples::make_tuple;
  25. using tuples::tie;
  26. #if !defined(BOOST_NO_USING_TEMPLATE)
  27. using tuples::get;
  28. #else
  29. //
  30. // The "using tuples::get" statement causes the
  31. // Borland compiler to ICE, use forwarding
  32. // functions instead:
  33. //
  34. template<int N, class HT, class TT>
  35. inline typename tuples::access_traits<
  36. typename tuples::element<N, tuples::cons<HT, TT> >::type
  37. >::non_const_type
  38. get(tuples::cons<HT, TT>& c) {
  39. return tuples::get<N,HT,TT>(c);
  40. }
  41. // get function for const cons-lists, returns a const reference to
  42. // the element. If the element is a reference, returns the reference
  43. // as such (that is, can return a non-const reference)
  44. template<int N, class HT, class TT>
  45. inline typename tuples::access_traits<
  46. typename tuples::element<N, tuples::cons<HT, TT> >::type
  47. >::const_type
  48. get(const tuples::cons<HT, TT>& c) {
  49. return tuples::get<N,HT,TT>(c);
  50. }
  51. #endif // BOOST_NO_USING_TEMPLATE
  52. } // end namespace boost
  53. #if !defined(BOOST_NO_CXX11_HDR_TUPLE)
  54. #include <tuple>
  55. #include <cstddef>
  56. namespace std
  57. {
  58. #if defined(BOOST_CLANG)
  59. # pragma clang diagnostic push
  60. # pragma clang diagnostic ignored "-Wmismatched-tags"
  61. #endif
  62. // std::tuple_size
  63. template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10>
  64. class tuple_size< boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >:
  65. public boost::tuples::length< boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  66. {
  67. };
  68. template<class H, class T> class tuple_size< boost::tuples::cons<H, T> >:
  69. public boost::tuples::length< boost::tuples::cons<H, T> >
  70. {
  71. };
  72. template<> class tuple_size< boost::tuples::null_type >:
  73. public boost::tuples::length< boost::tuples::null_type >
  74. {
  75. };
  76. // std::tuple_element
  77. template<std::size_t I, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10>
  78. class tuple_element< I, boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >:
  79. public boost::tuples::element< I, boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
  80. {
  81. };
  82. template<std::size_t I, class H, class T> class tuple_element< I, boost::tuples::cons<H, T> >:
  83. public boost::tuples::element< I, boost::tuples::cons<H, T> >
  84. {
  85. };
  86. #if defined(BOOST_CLANG)
  87. # pragma clang diagnostic pop
  88. #endif
  89. } // namespace std
  90. #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE)
  91. #endif // BOOST_TUPLE_HPP