1 // tuple.hpp - Boost Tuple Library --------------------------------------
3 // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
14 // For more information, see http://www.boost.org
16 // -----------------------------------------------------------------
18 #ifndef BOOST_TUPLE_HPP
19 #define BOOST_TUPLE_HPP
21 #if defined(__sgi) && defined(_COMPILER_VERSION) && _COMPILER_VERSION <= 730
22 // Work around a compiler bug.
23 // boost::python::tuple has to be seen by the compiler before the
24 // boost::tuple class template.
25 namespace boost { namespace python { class tuple; }}
28 #include "boost/config.hpp"
29 #include "boost/static_assert.hpp"
31 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
33 #include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp"
37 #include "boost/ref.hpp"
38 #include "boost/tuple/detail/tuple_basic.hpp"
40 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
45 using tuples::make_tuple;
47 #if !defined(BOOST_NO_USING_TEMPLATE)
49 #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
51 // The "using tuples::get" statement causes the
52 // Borland compiler to ICE, use forwarding
55 template<int N, class HT, class TT>
56 inline typename tuples::access_traits<
57 typename tuples::element<N, tuples::cons<HT, TT> >::type
59 get(tuples::cons<HT, TT>& c) {
60 return tuples::get<N,HT,TT>(c);
62 // get function for const cons-lists, returns a const reference to
63 // the element. If the element is a reference, returns the reference
64 // as such (that is, can return a non-const reference)
65 template<int N, class HT, class TT>
66 inline typename tuples::access_traits<
67 typename tuples::element<N, tuples::cons<HT, TT> >::type
69 get(const tuples::cons<HT, TT>& c) {
70 return tuples::get<N,HT,TT>(c);
72 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
74 // MSVC, using declarations don't mix with templates well,
75 // so use forwarding functions instead:
77 template<int N, typename Head, typename Tail>
78 typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET
79 get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
81 return tuples::detail::get_class<N>::get(t);
84 template<int N, typename Head, typename Tail>
85 typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET
86 get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
88 return tuples::detail::get_class<N>::get(t);
90 #endif // BOOST_NO_USING_TEMPLATE
92 } // end namespace boost
95 #endif // BOOST_TUPLE_HPP