| 1 | //  tuple.hpp - Boost Tuple Library -------------------------------------- | 
|---|
| 2 |  | 
|---|
| 3 | // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) | 
|---|
| 4 | // | 
|---|
| 5 | // Distributed under the Boost Software License, Version 1.0. (See | 
|---|
| 6 | // accompanying file LICENSE_1_0.txt or copy at | 
|---|
| 7 | // http://www.boost.org/LICENSE_1_0.txt) | 
|---|
| 8 |  | 
|---|
| 9 | // For more information, see http://www.boost.org | 
|---|
| 10 |  | 
|---|
| 11 | // -----------------------------------------------------------------  | 
|---|
| 12 |  | 
|---|
| 13 | #ifndef BOOST_TUPLE_HPP | 
|---|
| 14 | #define BOOST_TUPLE_HPP | 
|---|
| 15 |  | 
|---|
| 16 | #if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730 | 
|---|
| 17 | // Work around a compiler bug. | 
|---|
| 18 | // boost::python::tuple has to be seen by the compiler before the | 
|---|
| 19 | // boost::tuple class template. | 
|---|
| 20 | namespace boost { namespace python { class tuple; }} | 
|---|
| 21 | #endif | 
|---|
| 22 |  | 
|---|
| 23 | #include "boost/config.hpp" | 
|---|
| 24 | #include "boost/static_assert.hpp" | 
|---|
| 25 |  | 
|---|
| 26 | #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) | 
|---|
| 27 | // The MSVC version | 
|---|
| 28 | #include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp" | 
|---|
| 29 |  | 
|---|
| 30 | #else | 
|---|
| 31 | // other compilers | 
|---|
| 32 | #include "boost/ref.hpp" | 
|---|
| 33 | #include "boost/tuple/detail/tuple_basic.hpp" | 
|---|
| 34 |  | 
|---|
| 35 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | 
|---|
| 36 |  | 
|---|
| 37 | namespace boost {     | 
|---|
| 38 |  | 
|---|
| 39 | using tuples::tuple; | 
|---|
| 40 | using tuples::make_tuple; | 
|---|
| 41 | using tuples::tie; | 
|---|
| 42 | #if !defined(BOOST_NO_USING_TEMPLATE) | 
|---|
| 43 | using tuples::get; | 
|---|
| 44 | #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) | 
|---|
| 45 | // | 
|---|
| 46 | // The "using tuples::get" statement causes the | 
|---|
| 47 | // Borland compiler to ICE, use forwarding | 
|---|
| 48 | // functions instead: | 
|---|
| 49 | // | 
|---|
| 50 | template<int N, class HT, class TT> | 
|---|
| 51 | inline typename tuples::access_traits< | 
|---|
| 52 |                   typename tuples::element<N, tuples::cons<HT, TT> >::type | 
|---|
| 53 |                 >::non_const_type | 
|---|
| 54 | get(tuples::cons<HT, TT>& c) { | 
|---|
| 55 |   return tuples::get<N,HT,TT>(c); | 
|---|
| 56 | }  | 
|---|
| 57 | // get function for const cons-lists, returns a const reference to | 
|---|
| 58 | // the element. If the element is a reference, returns the reference | 
|---|
| 59 | // as such (that is, can return a non-const reference) | 
|---|
| 60 | template<int N, class HT, class TT> | 
|---|
| 61 | inline typename tuples::access_traits< | 
|---|
| 62 |                   typename tuples::element<N, tuples::cons<HT, TT> >::type | 
|---|
| 63 |                 >::const_type | 
|---|
| 64 | get(const tuples::cons<HT, TT>& c) { | 
|---|
| 65 |   return tuples::get<N,HT,TT>(c); | 
|---|
| 66 | } | 
|---|
| 67 | #else  // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION | 
|---|
| 68 | // | 
|---|
| 69 | // MSVC, using declarations don't mix with templates well, | 
|---|
| 70 | // so use forwarding functions instead: | 
|---|
| 71 | // | 
|---|
| 72 | template<int N, typename Head, typename Tail> | 
|---|
| 73 | typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET | 
|---|
| 74 | get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0) | 
|---|
| 75 | { | 
|---|
| 76 |    return tuples::detail::get_class<N>::get(t); | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | template<int N, typename Head, typename Tail> | 
|---|
| 80 | typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET | 
|---|
| 81 | get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0) | 
|---|
| 82 | { | 
|---|
| 83 |    return tuples::detail::get_class<N>::get(t); | 
|---|
| 84 | } | 
|---|
| 85 | #endif // BOOST_NO_USING_TEMPLATE | 
|---|
| 86 |     | 
|---|
| 87 | } // end namespace boost | 
|---|
| 88 |  | 
|---|
| 89 |  | 
|---|
| 90 | #endif // BOOST_TUPLE_HPP | 
|---|