1*f8a1b7d9SAlexander Kabaev // class template tuple -*- C++ -*- 2*f8a1b7d9SAlexander Kabaev 3*f8a1b7d9SAlexander Kabaev // Copyright (C) 2004, 2005 Free Software Foundation, Inc. 4*f8a1b7d9SAlexander Kabaev // 5*f8a1b7d9SAlexander Kabaev // This file is part of the GNU ISO C++ Library. This library is free 6*f8a1b7d9SAlexander Kabaev // software; you can redistribute it and/or modify it under the 7*f8a1b7d9SAlexander Kabaev // terms of the GNU General Public License as published by the 8*f8a1b7d9SAlexander Kabaev // Free Software Foundation; either version 2, or (at your option) 9*f8a1b7d9SAlexander Kabaev // any later version. 10*f8a1b7d9SAlexander Kabaev 11*f8a1b7d9SAlexander Kabaev // This library is distributed in the hope that it will be useful, 12*f8a1b7d9SAlexander Kabaev // but WITHOUT ANY WARRANTY; without even the implied warranty of 13*f8a1b7d9SAlexander Kabaev // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*f8a1b7d9SAlexander Kabaev // GNU General Public License for more details. 15*f8a1b7d9SAlexander Kabaev 16*f8a1b7d9SAlexander Kabaev // You should have received a copy of the GNU General Public License along 17*f8a1b7d9SAlexander Kabaev // with this library; see the file COPYING. If not, write to the Free 18*f8a1b7d9SAlexander Kabaev // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19*f8a1b7d9SAlexander Kabaev // USA. 20*f8a1b7d9SAlexander Kabaev 21*f8a1b7d9SAlexander Kabaev // As a special exception, you may use this file as part of a free software 22*f8a1b7d9SAlexander Kabaev // library without restriction. Specifically, if other files instantiate 23*f8a1b7d9SAlexander Kabaev // templates or use macros or inline functions from this file, or you compile 24*f8a1b7d9SAlexander Kabaev // this file and link it with other files to produce an executable, this 25*f8a1b7d9SAlexander Kabaev // file does not by itself cause the resulting executable to be covered by 26*f8a1b7d9SAlexander Kabaev // the GNU General Public License. This exception does not however 27*f8a1b7d9SAlexander Kabaev // invalidate any other reasons why the executable file might be covered by 28*f8a1b7d9SAlexander Kabaev // the GNU General Public License. 29*f8a1b7d9SAlexander Kabaev 30*f8a1b7d9SAlexander Kabaev /** @file tr1/tuple_defs.h 31*f8a1b7d9SAlexander Kabaev * This is an internal header file, included by other library headers. 32*f8a1b7d9SAlexander Kabaev * You should not attempt to use it directly. 33*f8a1b7d9SAlexander Kabaev */ 34*f8a1b7d9SAlexander Kabaev 35*f8a1b7d9SAlexander Kabaev #ifndef _GLIBCXX_REPEAT_HEADER 36*f8a1b7d9SAlexander Kabaev # define _GLIBCXX_REPEAT_HEADER "tuple_defs.h" 37*f8a1b7d9SAlexander Kabaev # include "repeat.h" 38*f8a1b7d9SAlexander Kabaev # undef _GLIBCXX_REPEAT_HEADER 39*f8a1b7d9SAlexander Kabaev #endif 40*f8a1b7d9SAlexander Kabaev 41*f8a1b7d9SAlexander Kabaev #ifdef _GLIBCXX_LAST_INCLUDE 42*f8a1b7d9SAlexander Kabaev // Chris Jefferson <[email protected]> 43*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS> class tuple; 44*f8a1b7d9SAlexander Kabaev 45*f8a1b7d9SAlexander Kabaev // Returns a const reference to the ith element of a tuple. 46*f8a1b7d9SAlexander Kabaev // Any const or non-const ref elements are returned with their original type. 47*f8a1b7d9SAlexander Kabaev template<int __i, _GLIBCXX_TEMPLATE_PARAMS> 48*f8a1b7d9SAlexander Kabaev typename __add_ref<typename tuple_element<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::type>::type get(tuple<_GLIBCXX_TEMPLATE_ARGS> & __t)49*f8a1b7d9SAlexander Kabaev get(tuple<_GLIBCXX_TEMPLATE_ARGS>& __t) 50*f8a1b7d9SAlexander Kabaev { 51*f8a1b7d9SAlexander Kabaev return __get_helper<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::get_value(__t); 52*f8a1b7d9SAlexander Kabaev } 53*f8a1b7d9SAlexander Kabaev 54*f8a1b7d9SAlexander Kabaev template<int __i, _GLIBCXX_TEMPLATE_PARAMS> 55*f8a1b7d9SAlexander Kabaev typename __add_c_ref<typename tuple_element<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::type>::type get(const tuple<_GLIBCXX_TEMPLATE_ARGS> & __t)56*f8a1b7d9SAlexander Kabaev get(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t) 57*f8a1b7d9SAlexander Kabaev { 58*f8a1b7d9SAlexander Kabaev return __get_helper<__i, tuple<_GLIBCXX_TEMPLATE_ARGS> >::get_value(__t); 59*f8a1b7d9SAlexander Kabaev } 60*f8a1b7d9SAlexander Kabaev 61*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U> 62*f8a1b7d9SAlexander Kabaev bool 63*f8a1b7d9SAlexander Kabaev operator==(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t, 64*f8a1b7d9SAlexander Kabaev const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u) 65*f8a1b7d9SAlexander Kabaev { 66*f8a1b7d9SAlexander Kabaev typedef tuple<_GLIBCXX_TEMPLATE_ARGS> _Tp; 67*f8a1b7d9SAlexander Kabaev typedef tuple<_GLIBCXX_TEMPLATE_ARGS_U> _Up; 68*f8a1b7d9SAlexander Kabaev return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0, 69*f8a1b7d9SAlexander Kabaev tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u); 70*f8a1b7d9SAlexander Kabaev } 71*f8a1b7d9SAlexander Kabaev 72*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U> 73*f8a1b7d9SAlexander Kabaev bool 74*f8a1b7d9SAlexander Kabaev operator<(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t, 75*f8a1b7d9SAlexander Kabaev const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u) 76*f8a1b7d9SAlexander Kabaev { 77*f8a1b7d9SAlexander Kabaev typedef tuple<_GLIBCXX_TEMPLATE_ARGS> _Tp; 78*f8a1b7d9SAlexander Kabaev typedef tuple<_GLIBCXX_TEMPLATE_ARGS_U> _Up; 79*f8a1b7d9SAlexander Kabaev return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0, 80*f8a1b7d9SAlexander Kabaev tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u); 81*f8a1b7d9SAlexander Kabaev } 82*f8a1b7d9SAlexander Kabaev 83*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U> 84*f8a1b7d9SAlexander Kabaev bool 85*f8a1b7d9SAlexander Kabaev operator!=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t, 86*f8a1b7d9SAlexander Kabaev const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u) 87*f8a1b7d9SAlexander Kabaev { return !(__t == __u); } 88*f8a1b7d9SAlexander Kabaev 89*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U> 90*f8a1b7d9SAlexander Kabaev bool 91*f8a1b7d9SAlexander Kabaev operator>(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t, 92*f8a1b7d9SAlexander Kabaev const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u) 93*f8a1b7d9SAlexander Kabaev { return __u < __t; } 94*f8a1b7d9SAlexander Kabaev 95*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U> 96*f8a1b7d9SAlexander Kabaev bool 97*f8a1b7d9SAlexander Kabaev operator<=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t, 98*f8a1b7d9SAlexander Kabaev const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u) 99*f8a1b7d9SAlexander Kabaev { return !(__u < __t); } 100*f8a1b7d9SAlexander Kabaev 101*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS, _GLIBCXX_TEMPLATE_PARAMS_U> 102*f8a1b7d9SAlexander Kabaev bool 103*f8a1b7d9SAlexander Kabaev operator>=(const tuple<_GLIBCXX_TEMPLATE_ARGS>& __t, 104*f8a1b7d9SAlexander Kabaev const tuple<_GLIBCXX_TEMPLATE_ARGS_U>& __u) 105*f8a1b7d9SAlexander Kabaev { return !(__t < __u); } 106*f8a1b7d9SAlexander Kabaev 107*f8a1b7d9SAlexander Kabaev template<_GLIBCXX_TEMPLATE_PARAMS_NULL_CLASS> 108*f8a1b7d9SAlexander Kabaev struct __stripped_tuple_type 109*f8a1b7d9SAlexander Kabaev { 110*f8a1b7d9SAlexander Kabaev typedef tuple<_GLIBCXX_TEMPLATE_ARGS_STRIPPED> __type; 111*f8a1b7d9SAlexander Kabaev }; 112*f8a1b7d9SAlexander Kabaev 113*f8a1b7d9SAlexander Kabaev #endif 114*f8a1b7d9SAlexander Kabaev 115