First public contribution.
1 // tuple.hpp - Boost Tuple Library --------------------------------------
3 // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
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)
9 // For more information, see http://www.boost.org
11 // -----------------------------------------------------------------
13 #ifndef BOOST_TUPLE_HPP
14 #define BOOST_TUPLE_HPP
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; }}
23 #include "boost/config.hpp"
24 #include "boost/static_assert.hpp"
26 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
28 #include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp"
32 #include "boost/ref.hpp"
33 #include "boost/tuple/detail/tuple_basic.hpp"
35 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
40 using tuples::make_tuple;
42 #if !defined(BOOST_NO_USING_TEMPLATE)
44 #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
46 // The "using tuples::get" statement causes the
47 // Borland compiler to ICE, use forwarding
50 template<int N, class HT, class TT>
51 inline typename tuples::access_traits<
52 typename tuples::element<N, tuples::cons<HT, TT> >::type
54 get(tuples::cons<HT, TT>& c) {
55 return tuples::get<N,HT,TT>(c);
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
64 get(const tuples::cons<HT, TT>& c) {
65 return tuples::get<N,HT,TT>(c);
67 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
69 // MSVC, using declarations don't mix with templates well,
70 // so use forwarding functions instead:
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)
76 return tuples::detail::get_class<N>::get(t);
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)
83 return tuples::detail::get_class<N>::get(t);
85 #endif // BOOST_NO_USING_TEMPLATE
87 } // end namespace boost
90 #endif // BOOST_TUPLE_HPP