tuple.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #endif // BOOST_TUPLE_HPP