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.
31 * This is an internal header file, included by other library headers.
32 * You should not attempt to use it directly.
35 // Chris Jefferson <chris@bubblescope.net>
37 /// @brief class tuple_size
38 template<_GLIBCXX_TEMPLATE_PARAMS>
39 struct tuple_size<tuple<_GLIBCXX_TEMPLATE_ARGS> >
40 { static const int value = _GLIBCXX_NUM_ARGS; };
42 template<_GLIBCXX_TEMPLATE_PARAMS>
43 #ifdef _GLIBCXX_LAST_INCLUDE
46 class tuple<_GLIBCXX_TEMPLATE_ARGS>
55 #if _GLIBCXX_NUM_ARGS == 2
56 template<class _U1, class _U2>
57 tuple(const std::pair<_U1, _U2>& __u):
58 _M_arg1(__u.first), _M_arg2(__u.second)
63 #if _GLIBCXX_NUM_ARGS > 0
64 explicit tuple(_GLIBCXX_TUPLE_ADD_CREF) :
65 _GLIBCXX_BIND_MEMBERS_INIT
68 template<_GLIBCXX_TEMPLATE_PARAMS_U>
69 tuple(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in) :
70 _GLIBCXX_TUPLE_COPY_INIT
74 template<_GLIBCXX_TEMPLATE_PARAMS_U>
76 operator=(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in)
82 tuple(const tuple& __in) :
83 _GLIBCXX_TUPLE_COPY_INIT
88 tuple(const tuple& __in)
94 operator=(const tuple& __in)
100 template<int __i, typename __Type>
101 friend class __get_helper;
103 template<typename, typename, typename, typename, typename,
104 typename, typename, typename, typename, typename>
108 #ifndef _GLIBCXX_LAST_INCLUDE
110 template<typename _Tp>
111 struct __get_helper<_GLIBCXX_NUM_ARGS, _Tp>
113 static typename __add_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
116 { return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
118 static typename __add_c_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
120 get_value(const _Tp& __in)
121 { return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
124 /// @brief class tuple_element
125 template<typename _T1, typename _T2, typename _T3, typename _T4,
126 typename _T5, typename _T6, typename _T7, typename _T8,
127 typename _T9, typename _T10>
128 struct tuple_element<_GLIBCXX_NUM_ARGS, tuple<_T1, _T2, _T3, _T4,
129 _T5, _T6, _T7, _T8, _T9,
131 { typedef _GLIBCXX_T_NUM_ARGS_PLUS_1 type; };
134 #if _GLIBCXX_NUM_ARGS == 0
138 { return tuple<>(); }
142 { return tuple<>(); }
145 template<_GLIBCXX_TEMPLATE_PARAMS>
146 typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::__type
147 make_tuple(_GLIBCXX_PARAMS)
149 return typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::
150 __type(_GLIBCXX_ARGS);
153 template<_GLIBCXX_TEMPLATE_PARAMS>
154 tuple<_GLIBCXX_REF_TEMPLATE_ARGS>
155 tie(_GLIBCXX_REF_PARAMS)
156 { return make_tuple(_GLIBCXX_REF_WRAP_PARAMS); }