// class template tuple -*- C++ -*- // Copyright (C) 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. // Chris Jefferson // This header is automatically generated: see maketuple.c for details. /** @file * This is a TR1 C++ Library header. */ #ifndef _TUPLE #define _TUPLE 1 #include namespace std { namespace tr1 { // An implementation specific class which is used in the tuple class // when the tuple is not maximum possible size. struct _NullClass { }; template class tuple; /// Gives the type of the ith element of a given tuple type. template struct tuple_element; template struct tuple_element<0, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp0 type; }; template struct tuple_element<1, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp1 type; }; template struct tuple_element<2, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp2 type; }; template struct tuple_element<3, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp3 type; }; template struct tuple_element<4, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp4 type; }; template struct tuple_element<5, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp5 type; }; template struct tuple_element<6, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp6 type; }; template struct tuple_element<7, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp7 type; }; template struct tuple_element<8, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp8 type; }; /// @brief class tuple_element template struct tuple_element<9, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> > { typedef _Tp9 type; }; /// Finds the size of a given tuple type. template struct tuple_size; template<> struct tuple_size > { static const int value = 0; }; template< typename _Tp0> struct tuple_size > { static const int value = 1; }; template struct tuple_size > { static const int value = 2; }; template struct tuple_size > { static const int value = 3; }; template struct tuple_size > { static const int value = 4; }; template struct tuple_size > { static const int value = 5; }; template struct tuple_size > { static const int value = 6; }; template struct tuple_size > { static const int value = 7; }; template struct tuple_size > { static const int value = 8; }; template struct tuple_size > { static const int value = 9; }; /// @brief class tuple_size template struct tuple_size > { static const int value = 10; }; // Adds a const reference to a non-reference type. template struct __add_c_ref { typedef const _Tp& type; }; template struct __add_c_ref<_Tp&> { typedef _Tp& type; }; // Adds a reference to a non-reference type. template struct __add_ref { typedef _Tp& type; }; template struct __add_ref<_Tp&> { typedef _Tp& type; }; // The empty tuple. template<> class tuple<_NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass> { public: tuple() { } tuple(const tuple& __in) { } tuple& operator=(const tuple& __in) { return *this; } }; template< typename _Tp0> class tuple< _Tp0, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; public: tuple() { } explicit tuple( typename __add_c_ref<_Tp0>::type __in0): _M_t0(__in0) { } tuple(const tuple& __in): _M_t0(__in._M_t0) { } template< typename _Up0> tuple(const tuple< _Up0>& __in): _M_t0(__in._M_t0) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; return *this; } template< typename _Up0> tuple& operator=(const tuple< _Up0>& __in) { _M_t0=__in._M_t0; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1): _M_t0(__in0), _M_t1(__in1) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1) { } template tuple(const tuple<_Up0, _Up1>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1) { } template tuple(const std::pair<_Up1, _Up2>& __u): _M_t0(__u.first), _M_t1(__u.second) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; return *this; } template tuple& operator=(const tuple<_Up0, _Up1>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2) { } template tuple(const tuple<_Up0, _Up1, _Up2>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _Tp3, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _NullClass, _NullClass, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; _Tp4 _M_t4; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3, typename __add_c_ref<_Tp4>::type __in4): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3), _M_t4(__in4) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _NullClass, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; _Tp4 _M_t4; _Tp5 _M_t5; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3, typename __add_c_ref<_Tp4>::type __in4, typename __add_c_ref<_Tp5>::type __in5): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3), _M_t4(__in4), _M_t5(__in5) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _NullClass, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; _Tp4 _M_t4; _Tp5 _M_t5; _Tp6 _M_t6; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3, typename __add_c_ref<_Tp4>::type __in4, typename __add_c_ref<_Tp5>::type __in5, typename __add_c_ref<_Tp6>::type __in6): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3), _M_t4(__in4), _M_t5(__in5), _M_t6(__in6) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _NullClass, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; _Tp4 _M_t4; _Tp5 _M_t5; _Tp6 _M_t6; _Tp7 _M_t7; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3, typename __add_c_ref<_Tp4>::type __in4, typename __add_c_ref<_Tp5>::type __in5, typename __add_c_ref<_Tp6>::type __in6, typename __add_c_ref<_Tp7>::type __in7): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3), _M_t4(__in4), _M_t5(__in5), _M_t6(__in6), _M_t7(__in7) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6), _M_t7(__in._M_t7) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6), _M_t7(__in._M_t7) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; _M_t7=__in._M_t7; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; _M_t7=__in._M_t7; return *this; } template friend class __get_helper; template friend class tuple; }; template class tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _NullClass> { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; _Tp4 _M_t4; _Tp5 _M_t5; _Tp6 _M_t6; _Tp7 _M_t7; _Tp8 _M_t8; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3, typename __add_c_ref<_Tp4>::type __in4, typename __add_c_ref<_Tp5>::type __in5, typename __add_c_ref<_Tp6>::type __in6, typename __add_c_ref<_Tp7>::type __in7, typename __add_c_ref<_Tp8>::type __in8): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3), _M_t4(__in4), _M_t5(__in5), _M_t6(__in6), _M_t7(__in7), _M_t8(__in8) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6), _M_t7(__in._M_t7), _M_t8(__in._M_t8) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6), _M_t7(__in._M_t7), _M_t8(__in._M_t8) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; _M_t7=__in._M_t7; _M_t8=__in._M_t8; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; _M_t7=__in._M_t7; _M_t8=__in._M_t8; return *this; } template friend class __get_helper; template friend class tuple; }; /// @brief Template class tuple template class tuple { _Tp0 _M_t0; _Tp1 _M_t1; _Tp2 _M_t2; _Tp3 _M_t3; _Tp4 _M_t4; _Tp5 _M_t5; _Tp6 _M_t6; _Tp7 _M_t7; _Tp8 _M_t8; _Tp9 _M_t9; public: tuple() { } explicit tuple(typename __add_c_ref<_Tp0>::type __in0, typename __add_c_ref<_Tp1>::type __in1, typename __add_c_ref<_Tp2>::type __in2, typename __add_c_ref<_Tp3>::type __in3, typename __add_c_ref<_Tp4>::type __in4, typename __add_c_ref<_Tp5>::type __in5, typename __add_c_ref<_Tp6>::type __in6, typename __add_c_ref<_Tp7>::type __in7, typename __add_c_ref<_Tp8>::type __in8, typename __add_c_ref<_Tp9>::type __in9): _M_t0(__in0), _M_t1(__in1), _M_t2(__in2), _M_t3(__in3), _M_t4(__in4), _M_t5(__in5), _M_t6(__in6), _M_t7(__in7), _M_t8(__in8), _M_t9(__in9) { } tuple(const tuple& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6), _M_t7(__in._M_t7), _M_t8(__in._M_t8), _M_t9(__in._M_t9) { } template tuple(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __in): _M_t0(__in._M_t0), _M_t1(__in._M_t1), _M_t2(__in._M_t2), _M_t3(__in._M_t3), _M_t4(__in._M_t4), _M_t5(__in._M_t5), _M_t6(__in._M_t6), _M_t7(__in._M_t7), _M_t8(__in._M_t8), _M_t9(__in._M_t9) { } tuple& operator=(const tuple& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; _M_t7=__in._M_t7; _M_t8=__in._M_t8; _M_t9=__in._M_t9; return *this; } template tuple& operator=(const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __in) { _M_t0=__in._M_t0; _M_t1=__in._M_t1; _M_t2=__in._M_t2; _M_t3=__in._M_t3; _M_t4=__in._M_t4; _M_t5=__in._M_t5; _M_t6=__in._M_t6; _M_t7=__in._M_t7; _M_t8=__in._M_t8; _M_t9=__in._M_t9; return *this; } template friend class __get_helper; template friend class tuple; }; // Class used in the implementation of get template struct __get_helper; template struct __get_helper<0, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t0; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t0; } }; template struct __get_helper<1, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t1; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t1; } }; template struct __get_helper<2, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t2; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t2; } }; template struct __get_helper<3, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t3; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t3; } }; template struct __get_helper<4, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t4; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t4; } }; template struct __get_helper<5, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t5; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t5; } }; template struct __get_helper<6, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t6; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t6; } }; template struct __get_helper<7, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t7; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t7; } }; template struct __get_helper<8, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t8; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t8; } }; template struct __get_helper<9, _Tp> { static typename __add_ref::type>::type get_value(_Tp& __in) { return __in._M_t9; } static typename __add_c_ref::type>::type get_value(const _Tp& __in) { return __in._M_t9; } }; /* Returns a reference to the ith element of a tuple. * Any const or non-const ref elements are returned with their original type */ template typename __add_ref >::type>::type get(tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t) { return __get_helper<__i, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> >::get_value(__t); } /* Returns a const reference to the ith element of a tuple. * Any const or non-const ref elements are returned with their original type */ template typename __add_c_ref >::type>::type get(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t) { return __get_helper<__i, tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> >::get_value(__t); } // This class helps construct the various comparison operations on tuples template struct __tuple_compare; template struct __tuple_compare<0, __i, __j, _Tp, _Up> { static bool __eq(const _Tp& __t, const _Up& __u) { return get<__i>(__t) == get<__i>(__u) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__eq(__t, __u); } static bool __neq(const _Tp& __t, const _Up& __u) { return get<__i>(__t) != get<__i>(__u) || __tuple_compare<0, __i+1, __j, _Tp, _Up>::__neq(__t, __u); } static bool __less(const _Tp& __t, const _Up& __u) { return (get<__i>(__t) < get<__i>(__u)) || !(get<__i>(__u) < get<__i>(__t)) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__less(__t, __u); } static bool __greater(const _Tp& __t, const _Up& __u) { return (get<__i>(__t) > get<__i>(__u)) || !(get<__i>(__u) > get<__i>(__t)) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__greater(__t, __u); } static bool __leq(const _Tp& __t, const _Up& __u) { return (get<__i>(__t) <= get<__i>(__u)) && (!(get<__i>(__u)<=get<__i>(__t)) || __tuple_compare<0, __i+1, __j, _Tp, _Up>::__leq(__t, __u)); } static bool __geq(const _Tp& __t, const _Up& __u) { return (get<__i>(__t) >= get<__i>(__u)) && (!(get<__i>(__u)>=get<__i>(__t)) || __tuple_compare<0, __i+1, __j, _Tp, _Up>::__geq(__t, __u)); } }; template struct __tuple_compare<0, __i, __i, _Tp, _Up> { static bool __eq(const _Tp&, const _Up&) { return true; } static bool __neq(const _Tp&, const _Up&) { return false; } static bool __leq(const _Tp&, const _Up&) { return true; } static bool __geq(const _Tp&, const _Up&) { return true; } static bool __less(const _Tp&, const _Up&) { return false; } static bool __greater(const _Tp&, const _Up&) { return false; } }; template bool operator==(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> __t_tuple; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9> __u_tuple; return __tuple_compare::value - tuple_size<__u_tuple>::value, 0, tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__eq(__t, __u); } template bool operator!=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> __t_tuple; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9> __u_tuple; return __tuple_compare::value - tuple_size<__u_tuple>::value, 0, tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__neq(__t, __u); } template bool operator<(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> __t_tuple; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9> __u_tuple; return __tuple_compare::value - tuple_size<__u_tuple>::value, 0, tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__less(__t, __u); } template bool operator>(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> __t_tuple; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9> __u_tuple; return __tuple_compare::value - tuple_size<__u_tuple>::value, 0, tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__greater(__t, __u); } template bool operator<=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> __t_tuple; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9> __u_tuple; return __tuple_compare::value - tuple_size<__u_tuple>::value, 0, tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__leq(__t, __u); } template bool operator>=(const tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>& __t, const tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9>& __u) { typedef tuple<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9> __t_tuple; typedef tuple<_Up0, _Up1, _Up2, _Up3, _Up4, _Up5, _Up6, _Up7, _Up8, _Up9> __u_tuple; return __tuple_compare::value - tuple_size<__u_tuple>::value, 0, tuple_size<__t_tuple>::value, __t_tuple, __u_tuple>::__geq(__t, __u); } // Provides a way to annotate that a reference to // an object should be passed. template class reference_wrapper { _Tp& _M_data; public: typedef _Tp type; explicit reference_wrapper(_Tp& __indata): _M_data(__indata) { } operator _Tp& () const { return this->get(); } _Tp& get() const { return _M_data; } }; // Denotes a reference should be taken to a variable. template reference_wrapper<_Tp> ref(_Tp& __t) { return reference_wrapper<_Tp>(__t); } // Denotes a const reference should be taken to a variable. template reference_wrapper<_Tp const> cref(const _Tp& __t) { return reference_wrapper<_Tp const>(__t); } // Helper which adds a reference to a type when given a reference_wrapper template struct __strip_reference_wrapper { typedef _Tp __type; }; template struct __strip_reference_wrapper > { typedef _Tp& __type; }; template struct __strip_reference_wrapper > { typedef _Tp& __type; }; template struct __stripped_tuple_type { typedef tuple::__type, typename __strip_reference_wrapper<_Tp1>::__type, typename __strip_reference_wrapper<_Tp2>::__type, typename __strip_reference_wrapper<_Tp3>::__type, typename __strip_reference_wrapper<_Tp4>::__type, typename __strip_reference_wrapper<_Tp5>::__type, typename __strip_reference_wrapper<_Tp6>::__type, typename __strip_reference_wrapper<_Tp7>::__type, typename __strip_reference_wrapper<_Tp8>::__type, typename __strip_reference_wrapper<_Tp9>::__type> __type; }; tuple<> make_tuple() { return tuple<>(); } template< typename _Tp0> typename __stripped_tuple_type< _Tp0>::__type make_tuple( _Tp0 __t0) { return typename __stripped_tuple_type< _Tp0>:: __type( __t0); } template typename __stripped_tuple_type<_Tp0, _Tp1>::__type make_tuple(_Tp0 __t0, _Tp1 __t1) { return typename __stripped_tuple_type<_Tp0, _Tp1>:: __type(__t0, __t1); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2>:: __type(__t0, __t1, __t2); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3>:: __type(__t0, __t1, __t2, __t3); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3, _Tp4 __t4) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4>:: __type(__t0, __t1, __t2, __t3, __t4); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3, _Tp4 __t4, _Tp5 __t5) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5>:: __type(__t0, __t1, __t2, __t3, __t4, __t5); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3, _Tp4 __t4, _Tp5 __t5, _Tp6 __t6) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6>:: __type(__t0, __t1, __t2, __t3, __t4, __t5, __t6); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3, _Tp4 __t4, _Tp5 __t5, _Tp6 __t6, _Tp7 __t7) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7>:: __type(__t0, __t1, __t2, __t3, __t4, __t5, __t6, __t7); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3, _Tp4 __t4, _Tp5 __t5, _Tp6 __t6, _Tp7 __t7, _Tp8 __t8) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8>:: __type(__t0, __t1, __t2, __t3, __t4, __t5, __t6, __t7, __t8); } template typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>::__type make_tuple(_Tp0 __t0, _Tp1 __t1, _Tp2 __t2, _Tp3 __t3, _Tp4 __t4, _Tp5 __t5, _Tp6 __t6, _Tp7 __t7, _Tp8 __t8, _Tp9 __t9) { return typename __stripped_tuple_type<_Tp0, _Tp1, _Tp2, _Tp3, _Tp4, _Tp5, _Tp6, _Tp7, _Tp8, _Tp9>:: __type(__t0, __t1, __t2, __t3, __t4, __t5, __t6, __t7, __t8, __t9); } // A class (and instance) which can be used in 'tie' when an element // of a tuple is not required struct swallow_assign { template swallow_assign& operator=(const T&) { return *this; } }; // TODO: Put this in some kind of shared file namespace { swallow_assign ignore; }; // Forms a tuple of references to a list of variables. template< typename _Tp0> tuple< _Tp0&> tie( _Tp0& __t0) { return make_tuple( ref(__t0)); }; template tuple<_Tp0&, _Tp1&> tie(_Tp0& __t0, _Tp1& __t1) { return make_tuple(ref(__t0), ref(__t1)); }; template tuple<_Tp0&, _Tp1&, _Tp2&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2) { return make_tuple(ref(__t0), ref(__t1), ref(__t2)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&, _Tp4&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3, _Tp4& __t4) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3), ref(__t4)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&, _Tp4&, _Tp5&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3, _Tp4& __t4, _Tp5& __t5) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3), ref(__t4), ref(__t5)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&, _Tp4&, _Tp5&, _Tp6&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3, _Tp4& __t4, _Tp5& __t5, _Tp6& __t6) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3), ref(__t4), ref(__t5), ref(__t6)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&, _Tp4&, _Tp5&, _Tp6&, _Tp7&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3, _Tp4& __t4, _Tp5& __t5, _Tp6& __t6, _Tp7& __t7) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3), ref(__t4), ref(__t5), ref(__t6), ref(__t7)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&, _Tp4&, _Tp5&, _Tp6&, _Tp7&, _Tp8&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3, _Tp4& __t4, _Tp5& __t5, _Tp6& __t6, _Tp7& __t7, _Tp8& __t8) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3), ref(__t4), ref(__t5), ref(__t6), ref(__t7), ref(__t8)); }; template tuple<_Tp0&, _Tp1&, _Tp2&, _Tp3&, _Tp4&, _Tp5&, _Tp6&, _Tp7&, _Tp8&, _Tp9&> tie(_Tp0& __t0, _Tp1& __t1, _Tp2& __t2, _Tp3& __t3, _Tp4& __t4, _Tp5& __t5, _Tp6& __t6, _Tp7& __t7, _Tp8& __t8, _Tp9& __t9) { return make_tuple(ref(__t0), ref(__t1), ref(__t2), ref(__t3), ref(__t4), ref(__t5), ref(__t6), ref(__t7), ref(__t8), ref(__t9)); }; // Various functions which give std::pair a tuple-like interface. template struct tuple_size > { static const int value = 2; }; template struct tuple_element<0, std::pair<_Tp1, _Tp2> > { typedef _Tp1 type; }; template struct tuple_element<1, std::pair<_Tp1, _Tp2> > { typedef _Tp2 type; }; template typename tuple_element<_Int, tuple<_Tp1, _Tp2> >::type get(pair<_Tp1, _Tp2>& __in) { return get<_Int>(tie(__in.first, __in.second)); } template typename tuple_element<_Int, tuple<_Tp1, _Tp2> >::type get(const pair<_Tp1, _Tp2>& __in) { return get<_Int>(tie(__in.first, __in.second)); } } } #endif