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