]> git.lyx.org Git - lyx.git/blob - boost/boost/tuple/tuple.hpp
The std::string mammoth path.
[lyx.git] / boost / boost / tuple / tuple.hpp
1 //  tuple.hpp - Boost Tuple Library --------------------------------------
2
3 // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
4 //
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.
10 //
11 // This software is provided "as is" without express or implied warranty, 
12 // and with no claim as to its suitability for any purpose.
13
14 // For more information, see http://www.boost.org
15
16 // ----------------------------------------------------------------- 
17
18 #ifndef BOOST_TUPLE_HPP
19 #define BOOST_TUPLE_HPP
20
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; }}
26 #endif
27
28 #include "boost/config.hpp"
29 #include "boost/static_assert.hpp"
30
31 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
32 // The MSVC version
33 #include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp"
34
35 #else
36 // other compilers
37 #include "boost/ref.hpp"
38 #include "boost/tuple/detail/tuple_basic.hpp"
39
40 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
41
42 namespace boost {    
43
44 using tuples::tuple;
45 using tuples::make_tuple;
46 using tuples::tie;
47 #if !defined(BOOST_NO_USING_TEMPLATE)
48 using tuples::get;
49 #elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
50 //
51 // The "using tuples::get" statement causes the
52 // Borland compiler to ICE, use forwarding
53 // functions instead:
54 //
55 template<int N, class HT, class TT>
56 inline typename tuples::access_traits<
57                   typename tuples::element<N, tuples::cons<HT, TT> >::type
58                 >::non_const_type
59 get(tuples::cons<HT, TT>& c) {
60   return tuples::get<N,HT,TT>(c);
61
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
68                 >::const_type
69 get(const tuples::cons<HT, TT>& c) {
70   return tuples::get<N,HT,TT>(c);
71 }
72 #else  // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
73 //
74 // MSVC, using declarations don't mix with templates well,
75 // so use forwarding functions instead:
76 //
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)
80 {
81    return tuples::detail::get_class<N>::get(t);
82 }
83
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)
87 {
88    return tuples::detail::get_class<N>::get(t);
89 }
90 #endif // BOOST_NO_USING_TEMPLATE
91    
92 } // end namespace boost
93
94
95 #endif // BOOST_TUPLE_HPP