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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
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<class _U1, class _U2>
00057         tuple(const std::pair<_U1, _U2>& __u):
00058            _M_arg1(__u.first), _M_arg2(__u.second)
00059         { }
00060 
00061 #endif
00062 
00063 #if _GLIBCXX_NUM_ARGS > 0
00064     explicit tuple(_GLIBCXX_TUPLE_ADD_CREF) :
00065       _GLIBCXX_BIND_MEMBERS_INIT
00066     { }
00067 
00068     template<_GLIBCXX_TEMPLATE_PARAMS_U>
00069       tuple(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in) :
00070       _GLIBCXX_TUPLE_COPY_INIT
00071     { }
00072 
00073 
00074     template<_GLIBCXX_TEMPLATE_PARAMS_U>
00075       tuple&
00076       operator=(const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __in)
00077       {
00078     _GLIBCXX_TUPLE_ASSIGN
00079     return *this;
00080       }
00081 
00082     tuple(const tuple& __in) :
00083       _GLIBCXX_TUPLE_COPY_INIT
00084     { }
00085 
00086 #else
00087 
00088     tuple(const tuple& __in)
00089     { }
00090 
00091 #endif
00092 
00093     tuple&
00094     operator=(const tuple& __in)
00095     {
00096       _GLIBCXX_TUPLE_ASSIGN
00097     return *this;
00098     }
00099 
00100     template<int __i, typename __Type>
00101       friend class __get_helper;
00102 
00103     template<typename, typename, typename, typename, typename,
00104              typename, typename, typename, typename, typename>
00105       friend class tuple;
00106   };
00107 
00108 #ifndef _GLIBCXX_LAST_INCLUDE
00109 
00110 template<typename _Tp>
00111     struct __get_helper<_GLIBCXX_NUM_ARGS, _Tp>
00112     {
00113       static typename __add_ref<typename tuple_element<_GLIBCXX_NUM_ARGS, 
00114                                                    _Tp>::type>::type
00115       get_value(_Tp& __in)
00116       { return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
00117 
00118       static typename __add_c_ref<typename tuple_element<_GLIBCXX_NUM_ARGS,
00119                                                      _Tp>::type>::type
00120       get_value(const _Tp& __in)
00121       { return __in._GLIBCXX_CAT(_M_arg,_GLIBCXX_NUM_ARGS_PLUS_1); }
00122     };
00123 
00124 /// @brief class tuple_element 
00125 template<typename _T1, typename _T2, typename _T3, typename _T4, 
00126          typename _T5, typename _T6, typename _T7, typename _T8, 
00127          typename _T9, typename _T10>
00128    struct tuple_element<_GLIBCXX_NUM_ARGS, tuple<_T1, _T2, _T3, _T4, 
00129                                                 _T5, _T6, _T7, _T8, _T9, 
00130                                                 _T10> >
00131   { typedef _GLIBCXX_T_NUM_ARGS_PLUS_1 type; };
00132 
00133 #endif
00134 #if _GLIBCXX_NUM_ARGS == 0
00135 
00136 tuple<>
00137 inline make_tuple()
00138 { return tuple<>(); }
00139 
00140 inline tuple<>
00141 tie()
00142 { return tuple<>(); }
00143 #else
00144 
00145 template<_GLIBCXX_TEMPLATE_PARAMS>
00146   typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::__type
00147   make_tuple(_GLIBCXX_PARAMS)
00148   { 
00149     return typename __stripped_tuple_type<_GLIBCXX_TEMPLATE_ARGS>::
00150       __type(_GLIBCXX_ARGS);
00151   }
00152 
00153 template<_GLIBCXX_TEMPLATE_PARAMS>
00154   tuple<_GLIBCXX_REF_TEMPLATE_ARGS>
00155   tie(_GLIBCXX_REF_PARAMS)
00156   { return make_tuple(_GLIBCXX_REF_WRAP_PARAMS); }
00157 #endif
00158 

Generated on Wed Apr 27 18:35:18 2005 for libstdc++ source by  doxygen 1.4.2