tuple_iterate.h

Go to the documentation of this file.
00001 // class template tuple -*- C++ -*-
00002 
00003 // Copyright (C) 2004, 2005 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 2, 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 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 /** @file
00031  *  This is an internal header file, included by other library headers.
00032  *  You should not attempt to use it directly.
00033  */
00034 
00035 // Chris Jefferson <chris@bubblescope.net>
00036 
00037 /// @brief class tuple_size
00038 template<_GLIBCXX_TEMPLATE_PARAMS>
00039   struct tuple_size<tuple<_GLIBCXX_TEMPLATE_ARGS> >
00040   { static const int value = _GLIBCXX_NUM_ARGS; };
00041 
00042 template<_GLIBCXX_TEMPLATE_PARAMS>
00043 #ifdef _GLIBCXX_LAST_INCLUDE
00044   class tuple
00045 #else
00046   class tuple<_GLIBCXX_TEMPLATE_ARGS>
00047 #endif
00048   {
00049     _GLIBCXX_BIND_MEMBERS
00050 
00051   public:
00052     tuple()
00053     { }
00054 
00055 #if _GLIBCXX_NUM_ARGS == 2
00056     template<typename _U1, typename _U2>
00057       tuple(const std::pair<_U1, _U2>& __u) :
00058       _M_arg1(__u.first), _M_arg2(__u.second)
00059       { }
00060 
00061     template<typename _U1, typename _U2>
00062       tuple&
00063       operator=(const std::pair<_U1, _U2>& __u)
00064       { 
00065     _M_arg1 = __u.first;
00066     _M_arg2 = __u.second;
00067     return *this;
00068       }
00069 #endif
00070 
00071 #if _GLIBCXX_NUM_ARGS > 0
00072     explicit tuple(_GLIBCXX_TUPLE_ADD_CREF) :
00073       _GLIBCXX_BIND_MEMBERS_INIT
00074     { }
00075 
00076     template<_GLIBCXX_TEMPLATE_PARAMS_U>
00077       tuple(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in) :
00078       _GLIBCXX_TUPLE_COPY_INIT
00079     { }
00080 
00081 
00082     template<_GLIBCXX_TEMPLATE_PARAMS_U>
00083       tuple&
00084       operator=(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in)
00085       {
00086         _GLIBCXX_TUPLE_ASSIGN
00087         return *this;
00088       }
00089 
00090     tuple(const tuple& __in) :
00091       _GLIBCXX_TUPLE_COPY_INIT
00092     { }
00093 
00094 #else
00095 
00096     tuple(const tuple&)
00097     { }
00098 
00099 #endif
00100 
00101     tuple&
00102     operator=(const tuple& __in __attribute__((__unused__)) )
00103     {
00104       _GLIBCXX_TUPLE_ASSIGN
00105         return *this;
00106     }
00107 
00108     template<int __i, typename __Type>
00109       friend class __get_helper;
00110 
00111     template<typename, typename, typename, typename, typename,
00112              typename, typename, typename, typename, typename>
00113       friend class tuple;
00114   };
00115 
00116 #ifndef _GLIBCXX_LAST_INCLUDE
00117 
00118 template<typename _Tp>
00119     struct __get_helper<_GLIBCXX_NUM_ARGS, _Tp>
00120     {
00121       static typename __add_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
00122                                                        _Tp>::type>::type
00123       get_value(_Tp& __in)
00124       { return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
00125 
00126       static typename __add_c_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
00127                                                          _Tp>::type>::type
00128       get_value(const _Tp& __in)
00129       { return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
00130     };
00131 
00132 /// @brief class tuple_element
00133 template<typename _T1, typename _T2, typename _T3, typename _T4,
00134          typename _T5, typename _T6, typename _T7, typename _T8,
00135          typename _T9, typename _T10>
00136    struct tuple_element<_GLIBCXX_NUM_ARGS, tuple<_T1, _T2, _T3, _T4,
00137                                                 _T5, _T6, _T7, _T8, _T9,
00138                                                 _T10> >
00139   { typedef _GLIBCXX_T_NUM_ARGS_PLUS_1 type; };
00140 
00141 #endif
00142 #if _GLIBCXX_NUM_ARGS == 0
00143 
00144 tuple<>
00145 inline make_tuple()
00146 { return tuple<>(); }
00147 
00148 tuple<>
00149 inline tie()
00150 { return tuple<>(); }
00151 #else
00152 
00153 template<_GLIBCXX_TEMPLATE_PARAMS>
00154   typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::__type
00155   inline make_tuple(_GLIBCXX_PARAMS)
00156   {
00157     return typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::
00158       __type(_GLIBCXX_ARGS);
00159   }
00160 
00161 template<_GLIBCXX_TEMPLATE_PARAMS>
00162   tuple<_GLIBCXX_REF_TEMPLATE_ARGS>
00163   inline tie(_GLIBCXX_REF_PARAMS)
00164   { return make_tuple(_GLIBCXX_REF_WRAP_PARAMS); }
00165 #endif
00166 

Generated on Thu Nov 1 17:36:02 2007 for libstdc++ by  doxygen 1.5.1