tuple_defs.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 tr1/tuple_defs.h
00031  *  This is an internal header file, included by other library headers.
00032  *  You should not attempt to use it directly.
00033  */
00034 
00035 #ifndef _GLIBCXX_REPEAT_HEADER
00036 #  define _GLIBCXX_REPEAT_HEADER "tuple_defs.h"
00037 #  include "repeat.h"
00038 #  undef _GLIBCXX_REPEAT_HEADER
00039 #endif
00040 
00041 #ifdef _GLIBCXX_LAST_INCLUDE
00042 // Chris Jefferson <chris@bubblescope.net>
00043    template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS> class tuple;
00044 
00045    // Returns a const reference to the ith element of a tuple.
00046    // Any const or non-const ref elements are returned with their original type.
00047    template<int __i, _GLIBCXX_TEMPLATE_PARAMS>
00048    typename __add_ref<typename tuple_element<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::type>::type
00049    get(tuple<_GLIBCXX_TEMPLATE_ARGS>& __t)
00050    {
00051      return __get_helper<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::get_value(__t);
00052    }
00053 
00054    template<int __i, _GLIBCXX_TEMPLATE_PARAMS>
00055    typename __add_c_ref<typename tuple_element<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::type>::type
00056    get(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t)
00057    {
00058      return __get_helper<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::get_value(__t);
00059    }
00060 
00061  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
00062  bool
00063  operator==(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
00064             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
00065  {
00066    typedef tuple<_GLIBCXX_TEMPLATE_ARGS> _Tp;
00067    typedef tuple<_GLIBCXX_TEMPLATE_ARGS_U> _Up;
00068    return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0,
00069                           tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u);
00070  }
00071 
00072  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
00073  bool
00074  operator<(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
00075            const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
00076  {
00077    typedef tuple<_GLIBCXX_TEMPLATE_ARGS> _Tp;
00078    typedef tuple<_GLIBCXX_TEMPLATE_ARGS_U> _Up;
00079    return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0,
00080                           tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u);
00081  }
00082 
00083  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
00084  bool
00085  operator!=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
00086             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
00087  { return !(__t == __u); }
00088 
00089  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
00090  bool
00091  operator>(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
00092            const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
00093  { return __u < __t; }
00094 
00095  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
00096  bool
00097  operator<=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
00098             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
00099  { return !(__u < __t); }
00100 
00101  template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U>
00102  bool
00103  operator>=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t,
00104             const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u)
00105  { return !(__t < __u); }
00106 
00107  template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS>
00108    struct __stripped_tuple_type
00109    {
00110      typedef tuple<_GLIBCXX_TEMPLATE_ARGS_STRIPPED>      __type;
00111    };
00112 
00113 #endif
00114 

Generated on Thu Nov 1 13:12:47 2007 for libstdc++ by  doxygen 1.5.1