1 // class template tuple -*- C++ -*-
3 // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 /** @file tuple_defs.h
31 * This is an internal header file, included by other library headers.
32 * You should not attempt to use it directly.
35 #ifndef _GLIBCXX_REPEAT_HEADER
36 # define _GLIBCXX_REPEAT_HEADER "tuple_defs.h"
38 # undef _GLIBCXX_REPEAT_HEADER
41 #ifdef _GLIBCXX_LAST_INCLUDE
42 // Chris Jefferson <chris@bubblescope.net>
43 template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS
> class tuple
;
45 // Returns a const reference to the ith element of a tuple.
46 // Any const or non-const ref elements are returned with their original type.
47 template<int __i
, _GLIBCXX_TEMPLATE_PARAMS
>
48 typename __add_ref
<typename tuple_element
<__i
, tuple
<_GLIBCXX_TEMPLATE_ARGS
> >::type
>::type
49 get(tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
)
51 return __get_helper
<__i
, tuple
<_GLIBCXX_TEMPLATE_ARGS
> >::get_value(__t
);
54 template<int __i
, _GLIBCXX_TEMPLATE_PARAMS
>
55 typename __add_c_ref
<typename tuple_element
<__i
, tuple
<_GLIBCXX_TEMPLATE_ARGS
> >::type
>::type
56 get(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
)
58 return __get_helper
<__i
, tuple
<_GLIBCXX_TEMPLATE_ARGS
> >::get_value(__t
);
61 template<_GLIBCXX_TEMPLATE_PARAMS
, _GLIBCXX_TEMPLATE_PARAMS_U
>
63 operator==(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
,
64 const tuple
<_GLIBCXX_TEMPLATE_ARGS_U
>& __u
)
66 typedef tuple
<_GLIBCXX_TEMPLATE_ARGS
> _Tp
;
67 typedef tuple
<_GLIBCXX_TEMPLATE_ARGS_U
> _Up
;
68 return __tuple_compare
<tuple_size
<_Tp
>::value
- tuple_size
<_Tp
>::value
, 0,
69 tuple_size
<_Tp
>::value
, _Tp
, _Up
>::__eq(__t
, __u
);
72 template<_GLIBCXX_TEMPLATE_PARAMS
, _GLIBCXX_TEMPLATE_PARAMS_U
>
74 operator<(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
,
75 const tuple
<_GLIBCXX_TEMPLATE_ARGS_U
>& __u
)
77 typedef tuple
<_GLIBCXX_TEMPLATE_ARGS
> _Tp
;
78 typedef tuple
<_GLIBCXX_TEMPLATE_ARGS_U
> _Up
;
79 return __tuple_compare
<tuple_size
<_Tp
>::value
- tuple_size
<_Tp
>::value
, 0,
80 tuple_size
<_Tp
>::value
, _Tp
, _Up
>::__less(__t
, __u
);
83 template<_GLIBCXX_TEMPLATE_PARAMS
, _GLIBCXX_TEMPLATE_PARAMS_U
>
85 operator!=(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
,
86 const tuple
<_GLIBCXX_TEMPLATE_ARGS_U
>& __u
)
87 { return !(__t
== __u
); }
89 template<_GLIBCXX_TEMPLATE_PARAMS
, _GLIBCXX_TEMPLATE_PARAMS_U
>
91 operator>(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
,
92 const tuple
<_GLIBCXX_TEMPLATE_ARGS_U
>& __u
)
95 template<_GLIBCXX_TEMPLATE_PARAMS
, _GLIBCXX_TEMPLATE_PARAMS_U
>
97 operator<=(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
,
98 const tuple
<_GLIBCXX_TEMPLATE_ARGS_U
>& __u
)
99 { return !(__u
< __t
); }
101 template<_GLIBCXX_TEMPLATE_PARAMS
, _GLIBCXX_TEMPLATE_PARAMS_U
>
103 operator>=(const tuple
<_GLIBCXX_TEMPLATE_ARGS
>& __t
,
104 const tuple
<_GLIBCXX_TEMPLATE_ARGS_U
>& __u
)
105 { return !(__t
< __u
); }
107 template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS
>
108 struct __stripped_tuple_type
110 typedef tuple
<_GLIBCXX_TEMPLATE_ARGS_STRIPPED
> __type
;