# tuple

Go to the documentation of this file.

    00001 // <tuple> -*- C++ -*-
    00002
    00003 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    00004 //
    00005 // This file is part of the GNU ISO C++ Library.  This library is free
    00006 // software; you can redistribute it and/or modify it under the
    00007 // terms of the GNU General Public License as published by the
    00008 // Free Software Foundation; either version 3, or (at your option)
    00009 // any later version.
    00010
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014 // GNU General Public License for more details.
    00015
    00016 // Under Section 7 of GPL version 3, you are granted additional
    00017 // permissions described in the GCC Runtime Library Exception, version
    00018 // 3.1, as published by the Free Software Foundation.
    00019
    00020 // You should have received a copy of the GNU General Public License and
    00021 // a copy of the GCC Runtime Library Exception along with this program;
    00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    00023 // <http://www.gnu.org/licenses/>.
    00024
    00025 /** @file include/tuple
    00026  *  This is a Standard C++ Library header.
    00027  */
    00028
    00029 #ifndef _GLIBCXX_TUPLE
    00030 #define _GLIBCXX_TUPLE 1
    00031
    00032 #pragma GCC system_header
    00033
    00034 #ifndef __GXX_EXPERIMENTAL_CXX0X__
    00035 # include <bits/c++0x_warning.h>
    00036 #else
    00037
    00038 #include <utility>
    00039
    00040 namespace std
    00041 {
    00042   // Adds a const reference to a non-reference type.
    00043   template<typename _Tp>
    00044     struct __add_c_ref
    00045     { typedef const _Tp& type; };
    00046
    00047   template<typename _Tp>
    00048     struct __add_c_ref<_Tp&>
    00049     { typedef _Tp& type; };
    00050
    00051   // Adds a reference to a non-reference type.
    00052   template<typename _Tp>
    00053     struct __add_ref
    00054     { typedef _Tp& type; };
    00055
    00056   template<typename _Tp>
    00057     struct __add_ref<_Tp&>
    00058     { typedef _Tp& type; };
    00059
    00060   template<std::size_t _Idx, typename _Head, bool _IsEmpty>
    00061     struct _Head_base;
    00062
    00063   template<std::size_t _Idx, typename _Head>
    00064     struct _Head_base<_Idx, _Head, true>
    00065     : public _Head
    00066     {
    00067       _Head_base()
    00068       : _Head() { }
    00069
    00070       _Head_base(const _Head& __h)
    00071       : _Head(__h) { }
    00072
    00073       template<typename _UHead>
    00074         _Head_base(_UHead&& __h)
    00075     : _Head(std::forward<_UHead>(__h)) { }
    00076
    00077       _Head&       _M_head()       { return *this; }
    00078       const _Head& _M_head() const { return *this; }
    00079
    00080       void _M_swap_impl(_Head&) { /* no-op */ }
    00081     };
    00082
    00083   template<std::size_t _Idx, typename _Head>
    00084     struct _Head_base<_Idx, _Head, false>
    00085     {
    00086       _Head_base()
    00087       : _M_head_impl() { }
    00088
    00089       _Head_base(const _Head& __h)
    00090       : _M_head_impl(__h) { }
    00091
    00092       template<typename _UHead>
    00093         _Head_base(_UHead&& __h)
    00094     : _M_head_impl(std::forward<_UHead>(__h)) { }
    00095
    00096       _Head&       _M_head()       { return _M_head_impl; }
    00097       const _Head& _M_head() const { return _M_head_impl; }
    00098
    00099       void
    00100       _M_swap_impl(_Head& __h)
    00101       {
    00102     using std::swap;
    00103     swap(__h, _M_head_impl);
    00104       }
    00105
    00106       _Head _M_head_impl;
    00107     };
    00108
    00109   /**
    00110    * Contains the actual implementation of the @c tuple template, stored
    00111    * as a recursive inheritance hierarchy from the first element (most
    00112    * derived class) to the last (least derived class). The @c Idx
    00113    * parameter gives the 0-based index of the element stored at this
    00114    * point in the hierarchy; we use it to implement a constant-time
    00115    * get() operation.
    00116    */
    00117   template<std::size_t _Idx, typename... _Elements>
    00118     struct _Tuple_impl;
    00119
    00120   /**
    00121    * Zero-element tuple implementation. This is the basis case for the
    00122    * inheritance recursion.
    00123    */
    00124   template<std::size_t _Idx>
    00125     struct _Tuple_impl<_Idx>
    00126     {
    00127     protected:
    00128       void _M_swap_impl(_Tuple_impl&) { /* no-op */ }
    00129     };
    00130
    00131   /**
    00132    * Recursive tuple implementation. Here we store the @c Head element
    00133    * and derive from a @c Tuple_impl containing the remaining elements
    00134    * (which contains the @c Tail).
    00135    */
    00136   template<std::size_t _Idx, typename _Head, typename... _Tail>
    00137     struct _Tuple_impl<_Idx, _Head, _Tail...>
    00138     : public _Tuple_impl<_Idx + 1, _Tail...>,
    00139       private _Head_base<_Idx, _Head, std::is_empty<_Head>::value>
    00140     {
    00141       typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
    00142       typedef _Head_base<_Idx, _Head, std::is_empty<_Head>::value> _Base;
    00143
    00144       _Head&            _M_head()       { return _Base::_M_head(); }
    00145       const _Head&      _M_head() const { return _Base::_M_head(); }
    00146
    00147       _Inherited&       _M_tail()       { return *this; }
    00148       const _Inherited& _M_tail() const { return *this; }
    00149
    00150       _Tuple_impl()
    00151       : _Inherited(), _Base() { }
    00152
    00153       explicit
    00154       _Tuple_impl(const _Head& __head, const _Tail&... __tail)
    00155       : _Inherited(__tail...), _Base(__head) { }
    00156
    00157       template<typename _UHead, typename... _UTail>
    00158         explicit
    00159         _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
    00160     : _Inherited(std::forward<_UTail>(__tail)...),
    00161       _Base(std::forward<_UHead>(__head)) { }
    00162
    00163       _Tuple_impl(const _Tuple_impl& __in)
    00164       : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
    00165
    00166       _Tuple_impl(_Tuple_impl&& __in)
    00167       : _Inherited(std::move(__in._M_tail())),
    00168     _Base(std::forward<_Head>(__in._M_head())) { }
    00169
    00170       template<typename... _UElements>
    00171         _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
    00172     : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
    00173
    00174       template<typename... _UElements>
    00175         _Tuple_impl(_Tuple_impl<_Idx, _UElements...>&& __in)
    00176     : _Inherited(std::move(__in._M_tail())),
    00177       _Base(std::move(__in._M_head())) { }
    00178
    00179       _Tuple_impl&
    00180       operator=(const _Tuple_impl& __in)
    00181       {
    00182     _M_head() = __in._M_head();
    00183     _M_tail() = __in._M_tail();
    00184     return *this;
    00185       }
    00186
    00187       _Tuple_impl&
    00188       operator=(_Tuple_impl&& __in)
    00189       {
    00190     _M_head() = std::move(__in._M_head());
    00191     _M_tail() = std::move(__in._M_tail());
    00192     return *this;
    00193       }
    00194
    00195       template<typename... _UElements>
    00196         _Tuple_impl&
    00197         operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
    00198         {
    00199       _M_head() = __in._M_head();
    00200       _M_tail() = __in._M_tail();
    00201       return *this;
    00202     }
    00203
    00204       template<typename... _UElements>
    00205         _Tuple_impl&
    00206         operator=(_Tuple_impl<_Idx, _UElements...>&& __in)
    00207         {
    00208       _M_head() = std::move(__in._M_head());
    00209       _M_tail() = std::move(__in._M_tail());
    00210       return *this;
    00211     }
    00212
    00213     protected:
    00214       void
    00215       _M_swap_impl(_Tuple_impl& __in)
    00216       {
    00217     _Base::_M_swap_impl(__in._M_head());
    00218     _Inherited::_M_swap_impl(__in._M_tail());
    00219       }
    00220     };
    00221
    00222   /// tuple
    00223   template<typename... _Elements>
    00224     class tuple : public _Tuple_impl<0, _Elements...>
    00225     {
    00226       typedef _Tuple_impl<0, _Elements...> _Inherited;
    00227
    00228     public:
    00229       tuple()
    00230       : _Inherited() { }
    00231
    00232       explicit
    00233       tuple(const _Elements&... __elements)
    00234       : _Inherited(__elements...) { }
    00235
    00236       template<typename... _UElements>
    00237         explicit
    00238         tuple(_UElements&&... __elements)
    00239     : _Inherited(std::forward<_UElements>(__elements)...) { }
    00240
    00241       tuple(const tuple& __in)
    00242       : _Inherited(static_cast<const _Inherited&>(__in)) { }
    00243
    00244       tuple(tuple&& __in)
    00245       : _Inherited(static_cast<_Inherited&&>(__in)) { }
    00246
    00247       template<typename... _UElements>
    00248         tuple(const tuple<_UElements...>& __in)
    00249     : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
    00250     { }
    00251
    00252       template<typename... _UElements>
    00253         tuple(tuple<_UElements...>&& __in)
    00254     : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
    00255
    00256       // XXX http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html
    00257       template<typename... _UElements>
    00258         tuple(tuple<_UElements...>& __in)
    00259     : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
    00260     { }
    00261
    00262       tuple&
    00263       operator=(const tuple& __in)
    00264       {
    00265     static_cast<_Inherited&>(*this) = __in;
    00266     return *this;
    00267       }
    00268
    00269       tuple&
    00270       operator=(tuple&& __in)
    00271       {
    00272     static_cast<_Inherited&>(*this) = std::move(__in);
    00273     return *this;
    00274       }
    00275
    00276       template<typename... _UElements>
    00277         tuple&
    00278         operator=(const tuple<_UElements...>& __in)
    00279         {
    00280       static_cast<_Inherited&>(*this) = __in;
    00281       return *this;
    00282     }
    00283
    00284       template<typename... _UElements>
    00285         tuple&
    00286         operator=(tuple<_UElements...>&& __in)
    00287         {
    00288       static_cast<_Inherited&>(*this) = std::move(__in);
    00289       return *this;
    00290     }
    00291
    00292       void
    00293       swap(tuple& __in)
    00294       { _Inherited::_M_swap_impl(__in); }
    00295     };
    00296
    00297
    00298   template<>
    00299     class tuple<>
    00300     {
    00301     public:
    00302       void swap(tuple&) { /* no-op */ }
    00303     };
    00304
    00305   /// tuple (2-element), with construction and assignment from a pair.
    00306   template<typename _T1, typename _T2>
    00307     class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
    00308     {
    00309       typedef _Tuple_impl<0, _T1, _T2> _Inherited;
    00310
    00311     public:
    00312       tuple()
    00313       : _Inherited() { }
    00314
    00315       explicit
    00316       tuple(const _T1& __a1, const _T2& __a2)
    00317       : _Inherited(__a1, __a2) { }
    00318
    00319       template<typename _U1, typename _U2>
    00320         explicit
    00321         tuple(_U1&& __a1, _U2&& __a2)
    00322     : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
    00323
    00324       tuple(const tuple& __in)
    00325       : _Inherited(static_cast<const _Inherited&>(__in)) { }
    00326
    00327       tuple(tuple&& __in)
    00328       : _Inherited(static_cast<_Inherited&&>(__in)) { }
    00329
    00330       template<typename _U1, typename _U2>
    00331         tuple(const tuple<_U1, _U2>& __in)
    00332     : _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { }
    00333
    00334       template<typename _U1, typename _U2>
    00335         tuple(tuple<_U1, _U2>&& __in)
    00336     : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { }
    00337
    00338       template<typename _U1, typename _U2>
    00339         tuple(const pair<_U1, _U2>& __in)
    00340     : _Inherited(__in.first, __in.second) { }
    00341
    00342       template<typename _U1, typename _U2>
    00343         tuple(pair<_U1, _U2>&& __in)
    00344     : _Inherited(std::forward<_U1>(__in.first),
    00345              std::forward<_U2>(__in.second)) { }
    00346
    00347       tuple&
    00348       operator=(const tuple& __in)
    00349       {
    00350     static_cast<_Inherited&>(*this) = __in;
    00351     return *this;
    00352       }
    00353
    00354       tuple&
    00355       operator=(tuple&& __in)
    00356       {
    00357     static_cast<_Inherited&>(*this) = std::move(__in);
    00358     return *this;
    00359       }
    00360
    00361       template<typename _U1, typename _U2>
    00362         tuple&
    00363         operator=(const tuple<_U1, _U2>& __in)
    00364         {
    00365       static_cast<_Inherited&>(*this) = __in;
    00366       return *this;
    00367     }
    00368
    00369       template<typename _U1, typename _U2>
    00370         tuple&
    00371         operator=(tuple<_U1, _U2>&& __in)
    00372         {
    00373       static_cast<_Inherited&>(*this) = std::move(__in);
    00374       return *this;
    00375     }
    00376
    00377       template<typename _U1, typename _U2>
    00378         tuple&
    00379         operator=(const pair<_U1, _U2>& __in)
    00380         {
    00381       this->_M_head() = __in.first;
    00382       this->_M_tail()._M_head() = __in.second;
    00383       return *this;
    00384     }
    00385
    00386       template<typename _U1, typename _U2>
    00387         tuple&
    00388         operator=(pair<_U1, _U2>&& __in)
    00389         {
    00390       this->_M_head() = std::move(__in.first);
    00391       this->_M_tail()._M_head() = std::move(__in.second);
    00392       return *this;
    00393     }
    00394
    00395       void
    00396       swap(tuple& __in)
    00397       {
    00398     using std::swap;
    00399     swap(this->_M_head(), __in._M_head());
    00400     swap(this->_M_tail()._M_head(), __in._M_tail()._M_head());
    00401       }
    00402     };
    00403
    00404
    00405   /// Gives the type of the ith element of a given tuple type.
    00406   template<std::size_t __i, typename _Tp>
    00407     struct tuple_element;
    00408
    00409   /**
    00410    * Recursive case for tuple_element: strip off the first element in
    00411    * the tuple and retrieve the (i-1)th element of the remaining tuple.
    00412    */
    00413   template<std::size_t __i, typename _Head, typename... _Tail>
    00414     struct tuple_element<__i, tuple<_Head, _Tail...> >
    00415     : tuple_element<__i - 1, tuple<_Tail...> > { };
    00416
    00417   /**
    00418    * Basis case for tuple_element: The first element is the one we're seeking.
    00419    */
    00420   template<typename _Head, typename... _Tail>
    00421     struct tuple_element<0, tuple<_Head, _Tail...> >
    00422     {
    00423       typedef _Head type;
    00424     };
    00425
    00426   /// Finds the size of a given tuple type.
    00427   template<typename _Tp>
    00428     struct tuple_size;
    00429
    00430   /// class tuple_size
    00431   template<typename... _Elements>
    00432     struct tuple_size<tuple<_Elements...> >
    00433     {
    00434       static const std::size_t value = sizeof...(_Elements);
    00435     };
    00436
    00437   template<typename... _Elements>
    00438     const std::size_t tuple_size<tuple<_Elements...> >::value;
    00439
    00440   template<std::size_t __i, typename _Head, typename... _Tail>
    00441     inline typename __add_ref<_Head>::type
    00442     __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t)
    00443     { return __t._M_head(); }
    00444
    00445   template<std::size_t __i, typename _Head, typename... _Tail>
    00446     inline typename __add_c_ref<_Head>::type
    00447     __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t)
    00448     { return __t._M_head(); }
    00449
    00450   // Return a reference (const reference) to the ith element of a tuple.
    00451   // Any const or non-const ref elements are returned with their original type.
    00452   template<std::size_t __i, typename... _Elements>
    00453     inline typename __add_ref<
    00454                       typename tuple_element<__i, tuple<_Elements...> >::type
    00455                     >::type
    00456     get(tuple<_Elements...>& __t)
    00457     { return __get_helper<__i>(__t); }
    00458
    00459   template<std::size_t __i, typename... _Elements>
    00460     inline typename __add_c_ref<
    00461                       typename tuple_element<__i, tuple<_Elements...> >::type
    00462                     >::type
    00463     get(const tuple<_Elements...>& __t)
    00464     { return __get_helper<__i>(__t); }
    00465
    00466   // This class helps construct the various comparison operations on tuples
    00467   template<std::size_t __check_equal_size, std::size_t __i, std::size_t __j,
    00468        typename _Tp, typename _Up>
    00469     struct __tuple_compare;
    00470
    00471   template<std::size_t __i, std::size_t __j, typename _Tp, typename _Up>
    00472     struct __tuple_compare<0, __i, __j, _Tp, _Up>
    00473     {
    00474       static bool __eq(const _Tp& __t, const _Up& __u)
    00475       {
    00476     return (get<__i>(__t) == get<__i>(__u) &&
    00477         __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u));
    00478       }
    00479
    00480       static bool __less(const _Tp& __t, const _Up& __u)
    00481       {
    00482     return ((get<__i>(__t) < get<__i>(__u))
    00483         || !(get<__i>(__u) < get<__i>(__t)) &&
    00484         __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u));
    00485       }
    00486     };
    00487
    00488   template<std::size_t __i, typename _Tp, typename _Up>
    00489     struct __tuple_compare<0, __i, __i, _Tp, _Up>
    00490     {
    00491       static bool __eq(const _Tp&, const _Up&)
    00492       { return true; }
    00493
    00494       static bool __less(const _Tp&, const _Up&)
    00495       { return false; }
    00496     };
    00497
    00498   template<typename... _TElements, typename... _UElements>
    00499     bool
    00500     operator==(const tuple<_TElements...>& __t,
    00501            const tuple<_UElements...>& __u)
    00502     {
    00503       typedef tuple<_TElements...> _Tp;
    00504       typedef tuple<_UElements...> _Up;
    00505       return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
    00506           0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u));
    00507     }
    00508
    00509   template<typename... _TElements, typename... _UElements>
    00510     bool
    00511     operator<(const tuple<_TElements...>& __t,
    00512           const tuple<_UElements...>& __u)
    00513     {
    00514       typedef tuple<_TElements...> _Tp;
    00515       typedef tuple<_UElements...> _Up;
    00516       return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
    00517           0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u));
    00518     }
    00519
    00520   template<typename... _TElements, typename... _UElements>
    00521     inline bool
    00522     operator!=(const tuple<_TElements...>& __t,
    00523            const tuple<_UElements...>& __u)
    00524     { return !(__t == __u); }
    00525
    00526   template<typename... _TElements, typename... _UElements>
    00527     inline bool
    00528     operator>(const tuple<_TElements...>& __t,
    00529           const tuple<_UElements...>& __u)
    00530     { return __u < __t; }
    00531
    00532   template<typename... _TElements, typename... _UElements>
    00533     inline bool
    00534     operator<=(const tuple<_TElements...>& __t,
    00535            const tuple<_UElements...>& __u)
    00536     { return !(__u < __t); }
    00537
    00538   template<typename... _TElements, typename... _UElements>
    00539     inline bool
    00540     operator>=(const tuple<_TElements...>& __t,
    00541            const tuple<_UElements...>& __u)
    00542     { return !(__t < __u); }
    00543
    00544   // NB: DR 705.
    00545   template<typename... _Elements>
    00546     inline tuple<typename __decay_and_strip<_Elements>::__type...>
    00547     make_tuple(_Elements&&... __args)
    00548     {
    00549       typedef tuple<typename __decay_and_strip<_Elements>::__type...>
    00550     __result_type;
    00551       return __result_type(std::forward<_Elements>(__args)...);
    00552     }
    00553
    00554   template<std::size_t...> struct __index_holder { };
    00555
    00556   template<std::size_t __i, typename _IdxHolder, typename... _Elements>
    00557     struct __index_holder_impl;
    00558
    00559   template<std::size_t __i, std::size_t... _Indexes, typename _IdxHolder,
    00560        typename... _Elements>
    00561     struct __index_holder_impl<__i, __index_holder<_Indexes...>,
    00562                    _IdxHolder, _Elements...>
    00563     {
    00564       typedef typename __index_holder_impl<__i + 1,
    00565                        __index_holder<_Indexes..., __i>,
    00566                        _Elements...>::type type;
    00567     };
    00568
    00569   template<std::size_t __i, std::size_t... _Indexes>
    00570     struct __index_holder_impl<__i, __index_holder<_Indexes...> >
    00571     { typedef __index_holder<_Indexes...> type; };
    00572
    00573   template<typename... _Elements>
    00574     struct __make_index_holder
    00575     : __index_holder_impl<0, __index_holder<>, _Elements...> { };
    00576
    00577   template<typename... _TElements, std::size_t... _TIdx,
    00578        typename... _UElements, std::size_t... _UIdx>
    00579     inline tuple<_TElements..., _UElements...>
    00580     __tuple_cat_helper(const tuple<_TElements...>& __t,
    00581                const __index_holder<_TIdx...>&,
    00582                        const tuple<_UElements...>& __u,
    00583                const __index_holder<_UIdx...>&)
    00584     { return tuple<_TElements..., _UElements...>(get<_TIdx>(__t)...,
    00585                          get<_UIdx>(__u)...); }
    00586
    00587   template<typename... _TElements, std::size_t... _TIdx,
    00588        typename... _UElements, std::size_t... _UIdx>
    00589     inline tuple<_TElements..., _UElements...>
    00590     __tuple_cat_helper(tuple<_TElements...>&& __t,
    00591                const __index_holder<_TIdx...>&,
    00592                const tuple<_UElements...>& __u,
    00593                const __index_holder<_UIdx...>&)
    00594     { return tuple<_TElements..., _UElements...>
    00595     (std::move(get<_TIdx>(__t))..., get<_UIdx>(__u)...); }
    00596
    00597   template<typename... _TElements, std::size_t... _TIdx,
    00598        typename... _UElements, std::size_t... _UIdx>
    00599     inline tuple<_TElements..., _UElements...>
    00600     __tuple_cat_helper(const tuple<_TElements...>& __t,
    00601                const __index_holder<_TIdx...>&,
    00602                tuple<_UElements...>&& __u,
    00603                const __index_holder<_UIdx...>&)
    00604     { return tuple<_TElements..., _UElements...>
    00605     (get<_TIdx>(__t)..., std::move(get<_UIdx>(__u))...); }
    00606
    00607   template<typename... _TElements, std::size_t... _TIdx,
    00608        typename... _UElements, std::size_t... _UIdx>
    00609     inline tuple<_TElements..., _UElements...>
    00610     __tuple_cat_helper(tuple<_TElements...>&& __t,
    00611                const __index_holder<_TIdx...>&,
    00612                tuple<_UElements...>&& __u,
    00613                const __index_holder<_UIdx...>&)
    00614     { return tuple<_TElements..., _UElements...>
    00615     (std::move(get<_TIdx>(__t))..., std::move(get<_UIdx>(__u))...); }
    00616
    00617   template<typename... _TElements, typename... _UElements>
    00618     inline tuple<_TElements..., _UElements...>
    00619     tuple_cat(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u)
    00620     {
    00621       return __tuple_cat_helper(__t, typename
    00622                 __make_index_holder<_TElements...>::type(),
    00623                 __u, typename
    00624                 __make_index_holder<_UElements...>::type());
    00625     }
    00626
    00627   template<typename... _TElements, typename... _UElements>
    00628     inline tuple<_TElements..., _UElements...>
    00629     tuple_cat(tuple<_TElements...>&& __t, const tuple<_UElements...>& __u)
    00630     {
    00631       return __tuple_cat_helper(std::move(__t), typename
    00632                  __make_index_holder<_TElements...>::type(),
    00633                  __u, typename
    00634                  __make_index_holder<_UElements...>::type());
    00635     }
    00636
    00637   template<typename... _TElements, typename... _UElements>
    00638     inline tuple<_TElements..., _UElements...>
    00639     tuple_cat(const tuple<_TElements...>& __t, tuple<_UElements...>&& __u)
    00640     {
    00641       return __tuple_cat_helper(__t, typename
    00642                 __make_index_holder<_TElements...>::type(),
    00643                 std::move(__u), typename
    00644                 __make_index_holder<_UElements...>::type());
    00645     }
    00646
    00647   template<typename... _TElements, typename... _UElements>
    00648     inline tuple<_TElements..., _UElements...>
    00649     tuple_cat(tuple<_TElements...>&& __t, tuple<_UElements...>&& __u)
    00650     {
    00651       return __tuple_cat_helper(std::move(__t), typename
    00652                 __make_index_holder<_TElements...>::type(),
    00653                 std::move(__u), typename
    00654                 __make_index_holder<_UElements...>::type());
    00655     }
    00656
    00657   template<typename... _Elements>
    00658     inline tuple<_Elements&...>
    00659     tie(_Elements&... __args)
    00660     { return tuple<_Elements&...>(__args...); }
    00661
    00662   template<typename... _Elements>
    00663     inline void
    00664     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
    00665     { __x.swap(__y); }
    00666
    00667   // A class (and instance) which can be used in 'tie' when an element
    00668   // of a tuple is not required
    00669   struct _Swallow_assign
    00670   {
    00671     template<class _Tp>
    00672       _Swallow_assign&
    00673       operator=(const _Tp&)
    00674       { return *this; }
    00675   };
    00676
    00677   // TODO: Put this in some kind of shared file.
    00678   namespace
    00679   {
    00680     _Swallow_assign ignore;
    00681   }; // anonymous namespace
    00682 }
    00683
    00684 #endif // __GXX_EXPERIMENTAL_CXX0X__
    00685
    00686 #endif // _GLIBCXX_TUPLE