]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/std/tuple
mips.md (GPR2): New mode iterator.
[thirdparty/gcc.git] / libstdc++-v3 / include / std / tuple
CommitLineData
af13a7a6
BK
1// <tuple> -*- C++ -*-
2
4312e020 3// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
af13a7a6
BK
4//
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)
9// any later version.
10
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.
15
16// You should have received a copy of the GNU General Public License
17// along with this library; see the file COPYING. If not, write to
18// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19// Boston, MA 02110-1301, USA.
20
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.
29
30/** @file include/tuple
31 * This is a Standard C++ Library header.
32 */
33
e133ace8
PC
34#ifndef _GLIBCXX_CXX0X_TUPLE
35#define _GLIBCXX_CXX0X_TUPLE 1
af13a7a6
BK
36
37#pragma GCC system_header
38
e133ace8 39#ifndef __GXX_EXPERIMENTAL_CXX0X__
af13a7a6
BK
40# include <c++0x_warning.h>
41#endif
42
e133ace8
PC
43#include <utility>
44
894d0b15
CF
45namespace std
46{
47 // Adds a const reference to a non-reference type.
48 template<typename _Tp>
49 struct __add_c_ref
50 { typedef const _Tp& type; };
51
52 template<typename _Tp>
53 struct __add_c_ref<_Tp&>
54 { typedef _Tp& type; };
55
56 // Adds a reference to a non-reference type.
57 template<typename _Tp>
58 struct __add_ref
59 { typedef _Tp& type; };
60
61 template<typename _Tp>
62 struct __add_ref<_Tp&>
63 { typedef _Tp& type; };
64
65 template<int _Idx, typename _Head, bool _IsEmpty>
ba60f6f9
PC
66 struct _Head_base;
67
894d0b15
CF
68 template<int _Idx, typename _Head>
69 struct _Head_base<_Idx, _Head, true>
70 : public _Head
71 {
72 _Head_base()
73 : _Head() { }
74
b5b5e640 75 _Head_base(const _Head& __h)
894d0b15
CF
76 : _Head(__h) { }
77
b5b5e640
PC
78 template<typename _UHead>
79 _Head_base(_UHead&& __h)
80 : _Head(std::forward<_UHead>(__h)) { }
894d0b15
CF
81
82 _Head& _M_head() { return *this; }
83 const _Head& _M_head() const { return *this; }
84 };
85
86 template<int _Idx, typename _Head>
87 struct _Head_base<_Idx, _Head, false>
88 {
89 _Head_base()
90 : _M_head_impl() { }
91
b5b5e640 92 _Head_base(const _Head& __h)
894d0b15
CF
93 : _M_head_impl(__h) { }
94
b5b5e640
PC
95 template<typename _UHead>
96 _Head_base(_UHead&& __h)
97 : _M_head_impl(std::forward<_UHead>(__h)) { }
894d0b15
CF
98
99 _Head& _M_head() { return _M_head_impl; }
100 const _Head& _M_head() const { return _M_head_impl; }
101
102 _Head _M_head_impl;
103 };
104
105 /**
894d0b15
CF
106 * Contains the actual implementation of the @c tuple template, stored
107 * as a recursive inheritance hierarchy from the first element (most
108 * derived class) to the last (least derived class). The @c Idx
109 * parameter gives the 0-based index of the element stored at this
110 * point in the hierarchy; we use it to implement a constant-time
111 * get() operation.
894d0b15
CF
112 */
113 template<int _Idx, typename... _Elements>
114 struct _Tuple_impl;
115
116 /**
894d0b15
CF
117 * Zero-element tuple implementation. This is the basis case for the
118 * inheritance recursion.
894d0b15
CF
119 */
120 template<int _Idx>
121 struct _Tuple_impl<_Idx> { };
122
123 /**
894d0b15
CF
124 * Recursive tuple implementation. Here we store the @c Head element
125 * and derive from a @c Tuple_impl containing the remaining elements
126 * (which contains the @c Tail).
894d0b15
CF
127 */
128 template<int _Idx, typename _Head, typename... _Tail>
129 struct _Tuple_impl<_Idx, _Head, _Tail...>
130 : public _Tuple_impl<_Idx + 1, _Tail...>,
131 private _Head_base<_Idx, _Head, std::is_empty<_Head>::value>
132 {
133 typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
134 typedef _Head_base<_Idx, _Head, std::is_empty<_Head>::value> _Base;
135
136 _Head& _M_head() { return _Base::_M_head(); }
137 const _Head& _M_head() const { return _Base::_M_head(); }
138
139 _Inherited& _M_tail() { return *this; }
140 const _Inherited& _M_tail() const { return *this; }
141
142 _Tuple_impl()
143 : _Inherited(), _Base() { }
144
145 explicit
b5b5e640 146 _Tuple_impl(const _Head& __head, const _Tail&... __tail)
894d0b15
CF
147 : _Inherited(__tail...), _Base(__head) { }
148
ba60f6f9
PC
149 template<typename _UHead, typename... _UTail>
150 explicit
b5b5e640
PC
151 _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
152 : _Inherited(std::forward<_UTail>(__tail)...),
153 _Base(std::forward<_UHead>(__head)) { }
894d0b15
CF
154
155 _Tuple_impl(const _Tuple_impl& __in)
156 : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
157
ba60f6f9 158 _Tuple_impl(_Tuple_impl&& __in)
b5b5e640
PC
159 : _Inherited(std::move<_Inherited&&>(__in._M_tail())),
160 _Base(std::forward<_Head>(__in._M_head())) { }
ba60f6f9 161
894d0b15 162 template<typename... _UElements>
ba60f6f9
PC
163 _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
164 : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
165
166 template<typename... _UElements>
167 _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in)
b5b5e640
PC
168 : _Inherited(std::move<typename _Tuple_impl<_Idx, _UElements...>::
169 _Inherited&&>(__in._M_tail())),
170 _Base(std::forward<typename _Tuple_impl<_Idx, _UElements...>::
171 _Base>(__in._M_head())) { }
894d0b15
CF
172
173 _Tuple_impl&
174 operator=(const _Tuple_impl& __in)
175 {
176 _M_head() = __in._M_head();
177 _M_tail() = __in._M_tail();
178 return *this;
179 }
ba60f6f9
PC
180
181 _Tuple_impl&
182 operator=(_Tuple_impl&& __in)
183 {
184 _M_head() = std::move(__in._M_head());
185 _M_tail() = std::move(__in._M_tail());
186 return *this;
187 }
188
189 template<typename... _UElements>
190 _Tuple_impl&
191 operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
192 {
193 _M_head() = __in._M_head();
194 _M_tail() = __in._M_tail();
195 return *this;
196 }
197
198 template<typename... _UElements>
199 _Tuple_impl&
200 operator=(_Tuple_impl<_Idx, _UElements...>&& __in)
201 {
202 _M_head() = std::move(__in._M_head());
203 _M_tail() = std::move(__in._M_tail());
204 return *this;
205 }
894d0b15
CF
206 };
207
939759fc 208 /// tuple
894d0b15
CF
209 template<typename... _Elements>
210 class tuple : public _Tuple_impl<0, _Elements...>
211 {
212 typedef _Tuple_impl<0, _Elements...> _Inherited;
213
214 public:
215 tuple()
216 : _Inherited() { }
217
218 explicit
ba60f6f9 219 tuple(const _Elements&... __elements)
894d0b15
CF
220 : _Inherited(__elements...) { }
221
222 template<typename... _UElements>
ba60f6f9
PC
223 explicit
224 tuple(_UElements&&... __elements)
b5b5e640 225 : _Inherited(std::forward<_UElements>(__elements)...) { }
894d0b15
CF
226
227 tuple(const tuple& __in)
b5b5e640 228 : _Inherited(static_cast<const _Inherited&>(__in)) { }
894d0b15 229
ba60f6f9 230 tuple(tuple&& __in)
b5b5e640 231 : _Inherited(std::move<_Inherited>(__in)) { }
ba60f6f9 232
894d0b15 233 template<typename... _UElements>
ba60f6f9 234 tuple(const tuple<_UElements...>& __in)
b5b5e640
PC
235 : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
236 { }
ba60f6f9
PC
237
238 template<typename... _UElements>
239 tuple(tuple<_UElements...>&& __in)
b5b5e640
PC
240 : _Inherited(std::move<_Tuple_impl<0, _UElements...> >(__in)) { }
241
242 // XXX http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html
243 template<typename... _UElements>
244 tuple(tuple<_UElements...>& __in)
245 : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
246 { }
894d0b15
CF
247
248 tuple&
249 operator=(const tuple& __in)
250 {
251 static_cast<_Inherited&>(*this) = __in;
252 return *this;
253 }
ba60f6f9
PC
254
255 tuple&
256 operator=(tuple&& __in)
257 {
258 static_cast<_Inherited&>(*this) = std::move(__in);
259 return *this;
260 }
261
262 template<typename... _UElements>
263 tuple&
264 operator=(const tuple<_UElements...>& __in)
265 {
266 static_cast<_Inherited&>(*this) = __in;
267 return *this;
268 }
269
270 template<typename... _UElements>
271 tuple&
272 operator=(tuple<_UElements...>&& __in)
273 {
274 static_cast<_Inherited&>(*this) = std::move(__in);
275 return *this;
276 }
894d0b15
CF
277 };
278
894d0b15 279
939759fc
BK
280 template<>
281 class tuple<> { };
282
283 /// tuple (2-element), with construction and assignment from a pair.
894d0b15
CF
284 template<typename _T1, typename _T2>
285 class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
286 {
287 typedef _Tuple_impl<0, _T1, _T2> _Inherited;
288
289 public:
290 tuple()
291 : _Inherited() { }
292
293 explicit
ba60f6f9 294 tuple(const _T1& __a1, const _T2& __a2)
894d0b15
CF
295 : _Inherited(__a1, __a2) { }
296
297 template<typename _U1, typename _U2>
ba60f6f9
PC
298 explicit
299 tuple(_U1&& __a1, _U2&& __a2)
300 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
894d0b15
CF
301
302 tuple(const tuple& __in)
b5b5e640 303 : _Inherited(static_cast<const _Inherited&>(__in)) { }
894d0b15 304
ba60f6f9 305 tuple(tuple&& __in)
b5b5e640 306 : _Inherited(std::move<_Inherited>(__in)) { }
ba60f6f9
PC
307
308 template<typename _U1, typename _U2>
309 tuple(const tuple<_U1, _U2>& __in)
b5b5e640 310 : _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { }
ba60f6f9
PC
311
312 template<typename _U1, typename _U2>
313 tuple(tuple<_U1, _U2>&& __in)
b5b5e640 314 : _Inherited(std::move<_Tuple_impl<0, _U1, _U2> >(__in)) { }
ba60f6f9 315
894d0b15
CF
316 template<typename _U1, typename _U2>
317 tuple(const pair<_U1, _U2>& __in)
b5b5e640 318 : _Inherited(__in.first, __in.second) { }
ba60f6f9 319
894d0b15 320 template<typename _U1, typename _U2>
ba60f6f9 321 tuple(pair<_U1, _U2>&& __in)
b5b5e640 322 : _Inherited(std::move(__in.first), std::move(__in.second)) { }
894d0b15
CF
323
324 tuple&
325 operator=(const tuple& __in)
326 {
327 static_cast<_Inherited&>(*this) = __in;
328 return *this;
329 }
330
ba60f6f9
PC
331 tuple&
332 operator=(tuple&& __in)
333 {
334 static_cast<_Inherited&>(*this) = std::move(__in);
335 return *this;
336 }
337
338 template<typename _U1, typename _U2>
339 tuple&
340 operator=(const tuple<_U1, _U2>& __in)
341 {
342 static_cast<_Inherited&>(*this) = __in;
343 return *this;
344 }
345
346 template<typename _U1, typename _U2>
347 tuple&
348 operator=(tuple<_U1, _U2>&& __in)
349 {
350 static_cast<_Inherited&>(*this) = std::move(__in);
351 return *this;
352 }
353
894d0b15
CF
354 template<typename _U1, typename _U2>
355 tuple&
356 operator=(const pair<_U1, _U2>& __in)
357 {
358 this->_M_head() = __in.first;
359 this->_M_tail()._M_head() = __in.second;
360 return *this;
361 }
ba60f6f9
PC
362
363 template<typename _U1, typename _U2>
364 tuple&
365 operator=(pair<_U1, _U2>&& __in)
366 {
367 this->_M_head() = std::move(__in.first);
368 this->_M_tail()._M_head() = std::move(__in.second);
369 return *this;
370 }
894d0b15
CF
371 };
372
373
374 /// Gives the type of the ith element of a given tuple type.
375 template<int __i, typename _Tp>
376 struct tuple_element;
377
378 /**
894d0b15
CF
379 * Recursive case for tuple_element: strip off the first element in
380 * the tuple and retrieve the (i-1)th element of the remaining tuple.
894d0b15
CF
381 */
382 template<int __i, typename _Head, typename... _Tail>
383 struct tuple_element<__i, tuple<_Head, _Tail...> >
384 : tuple_element<__i - 1, tuple<_Tail...> > { };
385
386 /**
894d0b15 387 * Basis case for tuple_element: The first element is the one we're seeking.
894d0b15
CF
388 */
389 template<typename _Head, typename... _Tail>
390 struct tuple_element<0, tuple<_Head, _Tail...> >
391 {
392 typedef _Head type;
393 };
394
395 /// Finds the size of a given tuple type.
396 template<typename _Tp>
397 struct tuple_size;
398
939759fc 399 /// class tuple_size
894d0b15
CF
400 template<typename... _Elements>
401 struct tuple_size<tuple<_Elements...> >
402 {
403 static const int value = sizeof...(_Elements);
404 };
405
406 template<typename... _Elements>
407 const int tuple_size<tuple<_Elements...> >::value;
408
409 template<int __i, typename _Head, typename... _Tail>
410 inline typename __add_ref<_Head>::type
411 __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t)
412 { return __t._M_head(); }
413
414 template<int __i, typename _Head, typename... _Tail>
415 inline typename __add_c_ref<_Head>::type
416 __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t)
417 { return __t._M_head(); }
418
419 // Return a reference (const reference) to the ith element of a tuple.
420 // Any const or non-const ref elements are returned with their original type.
421 template<int __i, typename... _Elements>
422 inline typename __add_ref<
423 typename tuple_element<__i, tuple<_Elements...> >::type
424 >::type
425 get(tuple<_Elements...>& __t)
426 { return __get_helper<__i>(__t); }
427
428 template<int __i, typename... _Elements>
429 inline typename __add_c_ref<
430 typename tuple_element<__i, tuple<_Elements...> >::type
431 >::type
432 get(const tuple<_Elements...>& __t)
433 { return __get_helper<__i>(__t); }
434
435 // This class helps construct the various comparison operations on tuples
436 template<int __check_equal_size, int __i, int __j,
437 typename _Tp, typename _Up>
438 struct __tuple_compare;
439
440 template<int __i, int __j, typename _Tp, typename _Up>
441 struct __tuple_compare<0, __i, __j, _Tp, _Up>
442 {
443 static bool __eq(const _Tp& __t, const _Up& __u)
444 {
445 return (get<__i>(__t) == get<__i>(__u) &&
446 __tuple_compare<0, __i+1, __j, _Tp, _Up>::__eq(__t, __u));
447 }
448
449 static bool __less(const _Tp& __t, const _Up& __u)
450 {
451 return ((get<__i>(__t) < get<__i>(__u))
452 || !(get<__i>(__u) < get<__i>(__t)) &&
453 __tuple_compare<0, __i+1, __j, _Tp, _Up>::__less(__t, __u));
454 }
455 };
456
457 template<int __i, typename _Tp, typename _Up>
458 struct __tuple_compare<0, __i, __i, _Tp, _Up>
459 {
460 static bool __eq(const _Tp&, const _Up&)
461 { return true; }
462
463 static bool __less(const _Tp&, const _Up&)
464 { return false; }
465 };
466
467 template<typename... _TElements, typename... _UElements>
468 bool
469 operator==(const tuple<_TElements...>& __t,
470 const tuple<_UElements...>& __u)
471 {
472 typedef tuple<_TElements...> _Tp;
473 typedef tuple<_UElements...> _Up;
230636fe 474 return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
894d0b15
CF
475 0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u));
476 }
477
478 template<typename... _TElements, typename... _UElements>
479 bool
480 operator<(const tuple<_TElements...>& __t,
481 const tuple<_UElements...>& __u)
482 {
483 typedef tuple<_TElements...> _Tp;
484 typedef tuple<_UElements...> _Up;
230636fe 485 return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
894d0b15
CF
486 0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u));
487 }
488
489 template<typename... _TElements, typename... _UElements>
490 inline bool
491 operator!=(const tuple<_TElements...>& __t,
492 const tuple<_UElements...>& __u)
493 { return !(__t == __u); }
494
495 template<typename... _TElements, typename... _UElements>
496 inline bool
497 operator>(const tuple<_TElements...>& __t,
498 const tuple<_UElements...>& __u)
499 { return __u < __t; }
500
501 template<typename... _TElements, typename... _UElements>
502 inline bool
503 operator<=(const tuple<_TElements...>& __t,
504 const tuple<_UElements...>& __u)
505 { return !(__u < __t); }
506
507 template<typename... _TElements, typename... _UElements>
508 inline bool
509 operator>=(const tuple<_TElements...>& __t,
510 const tuple<_UElements...>& __u)
511 { return !(__t < __u); }
512
513 // NB: DR 705.
514 template<typename... _Elements>
515 inline tuple<typename __decay_and_strip<_Elements>::__type...>
516 make_tuple(_Elements&&... __args)
517 {
518 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
519 __result_type;
520 return __result_type(std::forward<_Elements>(__args)...);
521 }
522
523 template<int...> struct __index_holder { };
524
525 template<int __i, typename _IdxHolder, typename... _Elements>
526 struct __index_holder_impl;
527
528 template<int __i, int... _Indexes, typename _IdxHolder, typename... _Elements>
529 struct __index_holder_impl<__i, __index_holder<_Indexes...>,
530 _IdxHolder, _Elements...>
531 {
532 typedef typename __index_holder_impl<__i + 1,
533 __index_holder<_Indexes..., __i>,
534 _Elements...>::type type;
535 };
536
537 template<int __i, int... _Indexes>
538 struct __index_holder_impl<__i, __index_holder<_Indexes...> >
539 { typedef __index_holder<_Indexes...> type; };
540
541 template<typename... _Elements>
542 struct __make_index_holder
543 : __index_holder_impl<0, __index_holder<>, _Elements...> { };
544
545 template<typename... _TElements, int... _TIdx,
546 typename... _UElements, int... _UIdx>
547 inline tuple<_TElements..., _UElements...>
548 __tuple_cat_helper(const tuple<_TElements...>& __t,
549 const __index_holder<_TIdx...>&,
550 const tuple<_UElements...>& __u,
551 const __index_holder<_UIdx...>&)
552 { return tuple<_TElements..., _UElements...>(get<_TIdx>(__t)...,
553 get<_UIdx>(__u)...); }
554
555 template<typename... _TElements, int... _TIdx,
556 typename... _UElements, int... _UIdx>
557 inline tuple<_TElements..., _UElements...>
558 __tuple_cat_helper(tuple<_TElements...>&& __t,
559 const __index_holder<_TIdx...>&,
560 const tuple<_UElements...>& __u,
561 const __index_holder<_UIdx...>&)
b5b5e640
PC
562 { return tuple<_TElements..., _UElements...>
563 (std::move(get<_TIdx>(__t))..., get<_UIdx>(__u)...); }
894d0b15
CF
564
565 template<typename... _TElements, int... _TIdx,
566 typename... _UElements, int... _UIdx>
567 inline tuple<_TElements..., _UElements...>
568 __tuple_cat_helper(const tuple<_TElements...>& __t,
569 const __index_holder<_TIdx...>&,
570 tuple<_UElements...>&& __u,
571 const __index_holder<_UIdx...>&)
b5b5e640
PC
572 { return tuple<_TElements..., _UElements...>
573 (get<_TIdx>(__t)..., std::move(get<_UIdx>(__u))...); }
894d0b15
CF
574
575 template<typename... _TElements, int... _TIdx,
576 typename... _UElements, int... _UIdx>
577 inline tuple<_TElements..., _UElements...>
578 __tuple_cat_helper(tuple<_TElements...>&& __t,
579 const __index_holder<_TIdx...>&,
580 tuple<_UElements...>&& __u,
581 const __index_holder<_UIdx...>&)
b5b5e640
PC
582 { return tuple<_TElements..., _UElements...>
583 (std::move(get<_TIdx>(__t))..., std::move(get<_UIdx>(__u))...); }
894d0b15
CF
584
585 template<typename... _TElements, typename... _UElements>
586 inline tuple<_TElements..., _UElements...>
587 tuple_cat(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u)
588 {
589 return __tuple_cat_helper(__t, typename
590 __make_index_holder<_TElements...>::type(),
591 __u, typename
592 __make_index_holder<_UElements...>::type());
593 }
594
595 template<typename... _TElements, typename... _UElements>
596 inline tuple<_TElements..., _UElements...>
597 tuple_cat(tuple<_TElements...>&& __t, const tuple<_UElements...>& __u)
598 {
599 return __tuple_cat_helper(std::move(__t), typename
600 __make_index_holder<_TElements...>::type(),
601 __u, typename
602 __make_index_holder<_UElements...>::type());
603 }
604
605 template<typename... _TElements, typename... _UElements>
606 inline tuple<_TElements..., _UElements...>
607 tuple_cat(const tuple<_TElements...>& __t, tuple<_UElements...>&& __u)
608 {
609 return __tuple_cat_helper(__t, typename
610 __make_index_holder<_TElements...>::type(),
611 std::move(__u), typename
612 __make_index_holder<_UElements...>::type());
613 }
614
615 template<typename... _TElements, typename... _UElements>
616 inline tuple<_TElements..., _UElements...>
617 tuple_cat(tuple<_TElements...>&& __t, tuple<_UElements...>&& __u)
618 {
619 return __tuple_cat_helper(std::move(__t), typename
620 __make_index_holder<_TElements...>::type(),
621 std::move(__u), typename
622 __make_index_holder<_UElements...>::type());
623 }
624
894d0b15
CF
625 template<typename... _Elements>
626 inline tuple<_Elements&...>
627 tie(_Elements&... __args)
628 { return tuple<_Elements&...>(__args...); }
629
630 // A class (and instance) which can be used in 'tie' when an element
631 // of a tuple is not required
632 struct _Swallow_assign
633 {
634 template<class _Tp>
635 _Swallow_assign&
636 operator=(const _Tp&)
637 { return *this; }
638 };
639
640 // TODO: Put this in some kind of shared file.
641 namespace
642 {
643 _Swallow_assign ignore;
644 }; // anonymous namespace
645}
af13a7a6 646
e133ace8 647#endif // _GLIBCXX_CXX0X_TUPLE