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 #include "boost/config.hpp"
22 #include "boost/static_assert.hpp"
24 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
26 #include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp"
30 #include "boost/ref.hpp"
31 #include "boost/tuple/detail/tuple_basic.hpp"
33 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
38 using tuples::make_tuple;
40 #if !defined(BOOST_NO_USING_TEMPLATE)
42 #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
44 // The "using tuples::get" statement causes the
45 // Borland compiler to ICE, use forwarding
48 template<int N, class HT, class TT>
49 inline typename tuples::access_traits<
50 typename tuples::element<N, tuples::cons<HT, TT> >::type
52 get(tuples::cons<HT, TT>& c) {
53 return tuples::get<N,HT,TT>(c);
55 // get function for const cons-lists, returns a const reference to
56 // the element. If the element is a reference, returns the reference
57 // as such (that is, can return a non-const reference)
58 template<int N, class HT, class TT>
59 inline typename tuples::access_traits<
60 typename tuples::element<N, tuples::cons<HT, TT> >::type
62 get(const tuples::cons<HT, TT>& c) {
63 return tuples::get<N,HT,TT>(c);
65 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
67 // MSVC, using declarations don't mix with templates well,
68 // so use forwarding functions instead:
70 template<int N, typename Head, typename Tail>
71 typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET
72 get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
74 return tuples::detail::get_class<N>::get(t);
77 template<int N, typename Head, typename Tail>
78 typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET
79 get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
81 return tuples::detail::get_class<N>::get(t);
83 #endif // BOOST_NO_USING_TEMPLATE
85 } // end namespace boost
88 #endif // BOOST_TUPLE_HPP