tuple

Go to the documentation of this file.
00001 // <tuple> -*- C++ -*-
00002 
00003 // Copyright (C) 2007, 2008, 2009 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 <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::move(__in.first), std::move(__in.second)) { }
00345 
00346       tuple&
00347       operator=(const tuple& __in)
00348       {
00349     static_cast<_Inherited&>(*this) = __in;
00350     return *this;
00351       }
00352 
00353       tuple&
00354       operator=(tuple&& __in)
00355       {
00356     static_cast<_Inherited&>(*this) = std::move(__in);
00357     return *this;
00358       }
00359 
00360       template<typename _U1, typename _U2>
00361         tuple&
00362         operator=(const tuple<_U1, _U2>& __in)
00363         {
00364       static_cast<_Inherited&>(*this) = __in;
00365       return *this;
00366     }
00367 
00368       template<typename _U1, typename _U2>
00369         tuple&
00370         operator=(tuple<_U1, _U2>&& __in)
00371         {
00372       static_cast<_Inherited&>(*this) = std::move(__in);
00373       return *this;
00374     }
00375 
00376       template<typename _U1, typename _U2>
00377         tuple&
00378         operator=(const pair<_U1, _U2>& __in)
00379         {
00380       this->_M_head() = __in.first;
00381       this->_M_tail()._M_head() = __in.second;
00382       return *this;
00383     }
00384 
00385       template<typename _U1, typename _U2>
00386         tuple&
00387         operator=(pair<_U1, _U2>&& __in)
00388         {
00389       this->_M_head() = std::move(__in.first);
00390       this->_M_tail()._M_head() = std::move(__in.second);
00391       return *this;
00392     }
00393 
00394       void
00395       swap(tuple& __in)
00396       { 
00397     using std::swap;
00398     swap(this->_M_head(), __in._M_head());
00399     swap(this->_M_tail()._M_head(), __in._M_tail()._M_head());  
00400       }
00401     };
00402 
00403 
00404   /// Gives the type of the ith element of a given tuple type.
00405   template<std::size_t __i, typename _Tp>
00406     struct tuple_element;
00407 
00408   /**
00409    * Recursive case for tuple_element: strip off the first element in
00410    * the tuple and retrieve the (i-1)th element of the remaining tuple.
00411    */
00412   template<std::size_t __i, typename _Head, typename... _Tail>
00413     struct tuple_element<__i, tuple<_Head, _Tail...> >
00414     : tuple_element<__i - 1, tuple<_Tail...> > { };
00415 
00416   /**
00417    * Basis case for tuple_element: The first element is the one we're seeking.
00418    */
00419   template<typename _Head, typename... _Tail>
00420     struct tuple_element<0, tuple<_Head, _Tail...> >
00421     {
00422       typedef _Head type;
00423     };
00424 
00425   /// Finds the size of a given tuple type.
00426   template<typename _Tp>
00427     struct tuple_size;
00428 
00429   /// class tuple_size
00430   template<typename... _Elements>
00431     struct tuple_size<tuple<_Elements...> >
00432     {
00433       static const std::size_t value = sizeof...(_Elements);
00434     };
00435 
00436   template<typename... _Elements>
00437     const std::size_t tuple_size<tuple<_Elements...> >::value;
00438 
00439   template<std::size_t __i, typename _Head, typename... _Tail>
00440     inline typename __add_ref<_Head>::type
00441     __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t)
00442     { return __t._M_head(); }
00443 
00444   template<std::size_t __i, typename _Head, typename... _Tail>
00445     inline typename __add_c_ref<_Head>::type
00446     __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t)
00447     { return __t._M_head(); }
00448 
00449   // Return a reference (const reference) to the ith element of a tuple.
00450   // Any const or non-const ref elements are returned with their original type.
00451   template<std::size_t __i, typename... _Elements>
00452     inline typename __add_ref<
00453                       typename tuple_element<__i, tuple<_Elements...> >::type
00454                     >::type
00455     get(tuple<_Elements...>& __t)
00456     { return __get_helper<__i>(__t); }
00457 
00458   template<std::size_t __i, typename... _Elements>
00459     inline typename __add_c_ref<
00460                       typename tuple_element<__i, tuple<_Elements...> >::type
00461                     >::type
00462     get(const tuple<_Elements...>& __t)
00463     { return __get_helper<__i>(__t); }
00464 
00465   // This class helps construct the various comparison operations on tuples
00466   template<std::size_t __check_equal_size, std::size_t __i, std::size_t __j,
00467        typename _Tp, typename _Up>
00468     struct __tuple_compare;
00469 
00470   template<std::size_t __i, std::size_t __j, typename _Tp, typename _Up>
00471     struct __tuple_compare<0, __i, __j, _Tp, _Up>
00472     {
00473       static bool __eq(const _Tp& __t, const _Up& __u)
00474       {
00475     return (get<__i>(__t) == get<__i>(__u) &&
00476         __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u));
00477       }
00478      
00479       static bool __less(const _Tp& __t, const _Up& __u)
00480       {
00481     return ((get<__i>(__t) < get<__i>(__u))
00482         || !(get<__i>(__u) < get<__i>(__t)) &&
00483         __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u));
00484       }
00485     };
00486 
00487   template<std::size_t __i, typename _Tp, typename _Up>
00488     struct __tuple_compare<0, __i, __i, _Tp, _Up>
00489     {
00490       static bool __eq(const _Tp&, const _Up&)
00491       { return true; }
00492      
00493       static bool __less(const _Tp&, const _Up&)
00494       { return false; }
00495     };
00496 
00497   template<typename... _TElements, typename... _UElements>
00498     bool
00499     operator==(const tuple<_TElements...>& __t,
00500            const tuple<_UElements...>& __u)
00501     {
00502       typedef tuple<_TElements...> _Tp;
00503       typedef tuple<_UElements...> _Up;
00504       return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
00505           0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u));
00506     }
00507 
00508   template<typename... _TElements, typename... _UElements>
00509     bool
00510     operator<(const tuple<_TElements...>& __t,
00511           const tuple<_UElements...>& __u)
00512     {
00513       typedef tuple<_TElements...> _Tp;
00514       typedef tuple<_UElements...> _Up;
00515       return (__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
00516           0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u));
00517     }
00518 
00519   template<typename... _TElements, typename... _UElements>
00520     inline bool
00521     operator!=(const tuple<_TElements...>& __t,
00522            const tuple<_UElements...>& __u)
00523     { return !(__t == __u); }
00524 
00525   template<typename... _TElements, typename... _UElements>
00526     inline bool
00527     operator>(const tuple<_TElements...>& __t,
00528           const tuple<_UElements...>& __u)
00529     { return __u < __t; }
00530 
00531   template<typename... _TElements, typename... _UElements>
00532     inline bool
00533     operator<=(const tuple<_TElements...>& __t,
00534            const tuple<_UElements...>& __u)
00535     { return !(__u < __t); }
00536 
00537   template<typename... _TElements, typename... _UElements>
00538     inline bool
00539     operator>=(const tuple<_TElements...>& __t,
00540            const tuple<_UElements...>& __u)
00541     { return !(__t < __u); }
00542 
00543   // NB: DR 705.
00544   template<typename... _Elements>
00545     inline tuple<typename __decay_and_strip<_Elements>::__type...>
00546     make_tuple(_Elements&&... __args)
00547     {
00548       typedef tuple<typename __decay_and_strip<_Elements>::__type...>
00549     __result_type;
00550       return __result_type(std::forward<_Elements>(__args)...);
00551     }
00552 
00553   template<std::size_t...> struct __index_holder { };    
00554 
00555   template<std::size_t __i, typename _IdxHolder, typename... _Elements>
00556     struct __index_holder_impl;
00557 
00558   template<std::size_t __i, std::size_t... _Indexes, typename _IdxHolder,
00559        typename... _Elements>
00560     struct __index_holder_impl<__i, __index_holder<_Indexes...>,
00561                    _IdxHolder, _Elements...> 
00562     {
00563       typedef typename __index_holder_impl<__i + 1,
00564                        __index_holder<_Indexes..., __i>,
00565                        _Elements...>::type type;
00566     };
00567  
00568   template<std::size_t __i, std::size_t... _Indexes>
00569     struct __index_holder_impl<__i, __index_holder<_Indexes...> >
00570     { typedef __index_holder<_Indexes...> type; };
00571 
00572   template<typename... _Elements>
00573     struct __make_index_holder 
00574     : __index_holder_impl<0, __index_holder<>, _Elements...> { };
00575     
00576   template<typename... _TElements, std::size_t... _TIdx,
00577        typename... _UElements, std::size_t... _UIdx> 
00578     inline tuple<_TElements..., _UElements...> 
00579     __tuple_cat_helper(const tuple<_TElements...>& __t,
00580                const __index_holder<_TIdx...>&,
00581                        const tuple<_UElements...>& __u,
00582                const __index_holder<_UIdx...>&)
00583     { return tuple<_TElements..., _UElements...>(get<_TIdx>(__t)...,
00584                          get<_UIdx>(__u)...); }
00585 
00586   template<typename... _TElements, std::size_t... _TIdx,
00587        typename... _UElements, std::size_t... _UIdx> 
00588     inline tuple<_TElements..., _UElements...> 
00589     __tuple_cat_helper(tuple<_TElements...>&& __t,
00590                const __index_holder<_TIdx...>&, 
00591                const tuple<_UElements...>& __u,
00592                const __index_holder<_UIdx...>&)
00593     { return tuple<_TElements..., _UElements...>
00594     (std::move(get<_TIdx>(__t))..., get<_UIdx>(__u)...); }
00595 
00596   template<typename... _TElements, std::size_t... _TIdx,
00597        typename... _UElements, std::size_t... _UIdx>
00598     inline tuple<_TElements..., _UElements...> 
00599     __tuple_cat_helper(const tuple<_TElements...>& __t,
00600                const __index_holder<_TIdx...>&, 
00601                tuple<_UElements...>&& __u,
00602                const __index_holder<_UIdx...>&)
00603     { return tuple<_TElements..., _UElements...>
00604     (get<_TIdx>(__t)..., std::move(get<_UIdx>(__u))...); }
00605 
00606   template<typename... _TElements, std::size_t... _TIdx,
00607        typename... _UElements, std::size_t... _UIdx> 
00608     inline tuple<_TElements..., _UElements...> 
00609     __tuple_cat_helper(tuple<_TElements...>&& __t,
00610                const __index_holder<_TIdx...>&, 
00611                tuple<_UElements...>&& __u,
00612                const __index_holder<_UIdx...>&)
00613     { return tuple<_TElements..., _UElements...>
00614     (std::move(get<_TIdx>(__t))..., std::move(get<_UIdx>(__u))...); }
00615 
00616   template<typename... _TElements, typename... _UElements>
00617     inline tuple<_TElements..., _UElements...> 
00618     tuple_cat(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u)
00619     {
00620       return __tuple_cat_helper(__t, typename
00621                 __make_index_holder<_TElements...>::type(),
00622                 __u, typename
00623                 __make_index_holder<_UElements...>::type());
00624     }
00625 
00626   template<typename... _TElements, typename... _UElements>
00627     inline tuple<_TElements..., _UElements...> 
00628     tuple_cat(tuple<_TElements...>&& __t, const tuple<_UElements...>& __u)
00629     {
00630       return __tuple_cat_helper(std::move(__t), typename
00631                  __make_index_holder<_TElements...>::type(),
00632                  __u, typename
00633                  __make_index_holder<_UElements...>::type());
00634     }
00635 
00636   template<typename... _TElements, typename... _UElements>
00637     inline tuple<_TElements..., _UElements...> 
00638     tuple_cat(const tuple<_TElements...>& __t, tuple<_UElements...>&& __u)
00639     {
00640       return __tuple_cat_helper(__t, typename
00641                 __make_index_holder<_TElements...>::type(),
00642                 std::move(__u), typename
00643                 __make_index_holder<_UElements...>::type());
00644     }
00645 
00646   template<typename... _TElements, typename... _UElements>
00647     inline tuple<_TElements..., _UElements...>
00648     tuple_cat(tuple<_TElements...>&& __t, tuple<_UElements...>&& __u)
00649     {
00650       return __tuple_cat_helper(std::move(__t), typename
00651                 __make_index_holder<_TElements...>::type(),
00652                 std::move(__u), typename
00653                 __make_index_holder<_UElements...>::type());
00654     }
00655 
00656   template<typename... _Elements>
00657     inline tuple<_Elements&...>
00658     tie(_Elements&... __args)
00659     { return tuple<_Elements&...>(__args...); }
00660 
00661   template<typename... _Elements>
00662     inline void 
00663     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
00664     { __x.swap(__y); }
00665 
00666   // A class (and instance) which can be used in 'tie' when an element
00667   // of a tuple is not required
00668   struct _Swallow_assign
00669   {
00670     template<class _Tp>
00671       _Swallow_assign&
00672       operator=(const _Tp&)
00673       { return *this; }
00674   };
00675 
00676   // TODO: Put this in some kind of shared file.
00677   namespace
00678   {
00679     _Swallow_assign ignore;
00680   }; // anonymous namespace
00681 }
00682 
00683 #endif // __GXX_EXPERIMENTAL_CXX0X__
00684 
00685 #endif // _GLIBCXX_TUPLE

Generated on 11 Jan 2010 for libstdc++ by  doxygen 1.6.1