1 | // tuple.hpp - Boost Tuple Library -------------------------------------- |
2 | |
3 | // Copyright (C) 1999, 2000 Jaakko Jarvi (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. |
20 | namespace boost { namespace python { class tuple; }} |
21 | #endif |
22 | |
23 | #include <boost/config.hpp> |
24 | #include <boost/static_assert.hpp> |
25 | |
26 | // other compilers |
27 | #include <boost/ref.hpp> |
28 | #include <boost/tuple/detail/tuple_basic.hpp> |
29 | |
30 | |
31 | namespace boost { |
32 | |
33 | using tuples::tuple; |
34 | using tuples::make_tuple; |
35 | using tuples::tie; |
36 | #if !defined(BOOST_NO_USING_TEMPLATE) |
37 | using tuples::get; |
38 | #else |
39 | // |
40 | // The "using tuples::get" statement causes the |
41 | // Borland compiler to ICE, use forwarding |
42 | // functions instead: |
43 | // |
44 | template<int N, class HT, class TT> |
45 | inline typename tuples::access_traits< |
46 | typename tuples::element<N, tuples::cons<HT, TT> >::type |
47 | >::non_const_type |
48 | get(tuples::cons<HT, TT>& c) { |
49 | return tuples::get<N,HT,TT>(c); |
50 | } |
51 | // get function for const cons-lists, returns a const reference to |
52 | // the element. If the element is a reference, returns the reference |
53 | // as such (that is, can return a non-const reference) |
54 | template<int N, class HT, class TT> |
55 | inline typename tuples::access_traits< |
56 | typename tuples::element<N, tuples::cons<HT, TT> >::type |
57 | >::const_type |
58 | get(const tuples::cons<HT, TT>& c) { |
59 | return tuples::get<N,HT,TT>(c); |
60 | } |
61 | |
62 | #endif // BOOST_NO_USING_TEMPLATE |
63 | |
64 | } // end namespace boost |
65 | |
66 | #if !defined(BOOST_NO_CXX11_HDR_TUPLE) |
67 | |
68 | #include <tuple> |
69 | #include <cstddef> |
70 | |
71 | namespace std |
72 | { |
73 | |
74 | #if defined(BOOST_CLANG) |
75 | # pragma clang diagnostic push |
76 | # pragma clang diagnostic ignored "-Wmismatched-tags" |
77 | #endif |
78 | |
79 | // std::tuple_size |
80 | |
81 | template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10> |
82 | class tuple_size< boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >: |
83 | public boost::tuples::length< boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > |
84 | { |
85 | }; |
86 | |
87 | template<class H, class T> class tuple_size< boost::tuples::cons<H, T> >: |
88 | public boost::tuples::length< boost::tuples::cons<H, T> > |
89 | { |
90 | }; |
91 | |
92 | template<> class tuple_size< boost::tuples::null_type >: |
93 | public boost::tuples::length< boost::tuples::null_type > |
94 | { |
95 | }; |
96 | |
97 | // std::tuple_element |
98 | |
99 | template<std::size_t I, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10> |
100 | class tuple_element< I, boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >: |
101 | public boost::tuples::element< I, boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > |
102 | { |
103 | }; |
104 | |
105 | template<std::size_t I, class H, class T> class tuple_element< I, boost::tuples::cons<H, T> >: |
106 | public boost::tuples::element< I, boost::tuples::cons<H, T> > |
107 | { |
108 | }; |
109 | |
110 | #if defined(BOOST_CLANG) |
111 | # pragma clang diagnostic pop |
112 | #endif |
113 | |
114 | } // namespace std |
115 | |
116 | #endif // !defined(BOOST_NO_CXX11_HDR_TUPLE) |
117 | |
118 | #endif // BOOST_TUPLE_HPP |
119 | |