source: NonGTP/Boost/boost/tuple/tuple.hpp @ 857

Revision 857, 2.9 KB checked in by igarcia, 19 years ago (diff)
Line 
1//  tuple.hpp - Boost Tuple Library --------------------------------------
2
3// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
4//
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)
8
9// For more information, see http://www.boost.org
10
11// -----------------------------------------------------------------
12
13#ifndef BOOST_TUPLE_HPP
14#define BOOST_TUPLE_HPP
15
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.
20namespace boost { namespace python { class tuple; }}
21#endif
22
23#include "boost/config.hpp"
24#include "boost/static_assert.hpp"
25
26#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
27// The MSVC version
28#include "boost/tuple/detail/tuple_basic_no_partial_spec.hpp"
29
30#else
31// other compilers
32#include "boost/ref.hpp"
33#include "boost/tuple/detail/tuple_basic.hpp"
34
35#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
36
37namespace boost {   
38
39using tuples::tuple;
40using tuples::make_tuple;
41using tuples::tie;
42#if !defined(BOOST_NO_USING_TEMPLATE)
43using tuples::get;
44#elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
45//
46// The "using tuples::get" statement causes the
47// Borland compiler to ICE, use forwarding
48// functions instead:
49//
50template<int N, class HT, class TT>
51inline typename tuples::access_traits<
52                  typename tuples::element<N, tuples::cons<HT, TT> >::type
53                >::non_const_type
54get(tuples::cons<HT, TT>& c) {
55  return tuples::get<N,HT,TT>(c);
56}
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)
60template<int N, class HT, class TT>
61inline typename tuples::access_traits<
62                  typename tuples::element<N, tuples::cons<HT, TT> >::type
63                >::const_type
64get(const tuples::cons<HT, TT>& c) {
65  return tuples::get<N,HT,TT>(c);
66}
67#else  // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
68//
69// MSVC, using declarations don't mix with templates well,
70// so use forwarding functions instead:
71//
72template<int N, typename Head, typename Tail>
73typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET
74get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
75{
76   return tuples::detail::get_class<N>::get(t);
77}
78
79template<int N, typename Head, typename Tail>
80typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET
81get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
82{
83   return tuples::detail::get_class<N>::get(t);
84}
85#endif // BOOST_NO_USING_TEMPLATE
86   
87} // end namespace boost
88
89
90#endif // BOOST_TUPLE_HPP
Note: See TracBrowser for help on using the repository browser.