2004-10-25 21:05:58 +02:00
|
|
|
// class template tuple -*- C++ -*-
|
|
|
|
|
2005-02-22 18:07:07 +01:00
|
|
|
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
2004-10-25 21:05:58 +02:00
|
|
|
//
|
|
|
|
// 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
|
2005-08-17 04:28:44 +02:00
|
|
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
2004-10-25 21:05:58 +02:00
|
|
|
// USA.
|
|
|
|
|
2005-02-22 18:07:07 +01:00
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
2005-04-01 05:35:59 +02:00
|
|
|
/** @file
|
|
|
|
* This is a TR1 C++ Library header.
|
|
|
|
*/
|
locale_facets.h (isspace, [...]): Add doxygen markup.
2004-11-22 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/locale_facets.h (isspace, isprint, isupper,
islower, isalpha, isdigit, ispunct, isxdigit, isalnum, isgraph,
toupper, tolower): Add doxygen markup.
(codecvt_byname, ctype_byname, numpunct_byname, collate_byname,
time_get_byname, time_put_byname, moneypunct_byname,
messages_byname): Same.
* include/std/std_fstream.h: Remove superfluous markup.
* include/std/std_sstream.h: Same.
* include/std/std_streambuf.h: Same.
* include/ext/enc_filebuf.h: Adjust markup.
* include/ext/stdio_filebuf.h: Same.
* include/ext/stdio_sync_filebuf.h: Same.
* include/bits/codecvt.h: Same.
* config/os/gnu-linux/ctype_base.h: Same.
* config/locale/ieee_1003.1-2001/codecvt_specializations.h: Same.
* include/tr1/array: Add markup.
* include/tr1/tuple: Same.
* docs/doxygen/run_doxygen: Print arguments.
* docs/doxygen/user.cfg.in: Tweaks.
From-SVN: r91080
2004-11-23 10:18:41 +01:00
|
|
|
|
2004-11-24 17:04:47 +01:00
|
|
|
// Chris Jefferson <chris@bubblescope.net>
|
|
|
|
|
2004-10-25 21:05:58 +02:00
|
|
|
#ifndef _TUPLE
|
|
|
|
#define _TUPLE 1
|
|
|
|
|
2004-11-24 17:04:47 +01:00
|
|
|
#include <tr1/utility>
|
2005-04-01 05:35:59 +02:00
|
|
|
#include <tr1/ref_fwd.h>
|
2004-10-25 21:05:58 +02:00
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
2005-12-19 01:56:05 +01:00
|
|
|
_GLIBCXX_BEGIN_NAMESPACE(tr1)
|
|
|
|
|
2005-04-01 05:35:59 +02:00
|
|
|
// An implementation specific class which is used in the tuple class
|
|
|
|
// when the tuple is not maximum possible size.
|
|
|
|
struct _NullClass { };
|
|
|
|
|
|
|
|
template<typename _Tp0 = _NullClass, typename _Tp1 = _NullClass,
|
|
|
|
typename _Tp2 = _NullClass, typename _Tp3 = _NullClass,
|
|
|
|
typename _Tp4 = _NullClass, typename _Tp5 = _NullClass,
|
|
|
|
typename _Tp6 = _NullClass, typename _Tp7 = _NullClass,
|
|
|
|
typename _Tp8 = _NullClass, typename _Tp9 = _NullClass>
|
|
|
|
class tuple;
|
|
|
|
|
|
|
|
/// Gives the type of the ith element of a given tuple type.
|
|
|
|
template<int __i, typename _Tp>
|
|
|
|
struct tuple_element;
|
|
|
|
|
|
|
|
/// Finds the size of a given tuple type.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct tuple_size;
|
|
|
|
|
|
|
|
// Adds a const reference to a non-reference type.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __add_c_ref
|
|
|
|
{ typedef const _Tp& type; };
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __add_c_ref<_Tp&>
|
|
|
|
{ typedef _Tp& type; };
|
|
|
|
|
|
|
|
// Adds a reference to a non-reference type.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __add_ref
|
|
|
|
{ typedef _Tp& type; };
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __add_ref<_Tp&>
|
|
|
|
{ typedef _Tp& type; };
|
|
|
|
|
|
|
|
// Class used in the implementation of get
|
|
|
|
template<int __i, typename _Tp>
|
|
|
|
struct __get_helper;
|
|
|
|
|
|
|
|
// 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<int __i, typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3,
|
|
|
|
typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
|
|
|
|
typename _Tp8, typename _Tp9>
|
|
|
|
typename __add_ref<typename tuple_element<__i, tuple<_Tp0, _Tp1, _Tp2,
|
|
|
|
_Tp3, _Tp4, _Tp5,
|
|
|
|
_Tp6, _Tp7, _Tp8,
|
|
|
|
_Tp9> >::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);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<int __i, typename _Tp0, typename _Tp1, typename _Tp2, typename _Tp3,
|
|
|
|
typename _Tp4, typename _Tp5, typename _Tp6, typename _Tp7,
|
|
|
|
typename _Tp8, typename _Tp9>
|
|
|
|
typename __add_c_ref<typename tuple_element<__i, tuple<_Tp0, _Tp1, _Tp2,
|
|
|
|
_Tp3, _Tp4, _Tp5,
|
|
|
|
_Tp6, _Tp7, _Tp8,
|
|
|
|
_Tp9> >::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<int __check_equal_size, int __i, int __j, typename _Tp, typename _Up>
|
|
|
|
struct __tuple_compare;
|
|
|
|
|
|
|
|
template<int __i, int __j, typename _Tp, typename _Up>
|
|
|
|
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 __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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<int __i, typename _Tp, typename _Up>
|
|
|
|
struct __tuple_compare<0, __i, __i, _Tp, _Up>
|
|
|
|
{
|
|
|
|
static bool __eq(const _Tp&, const _Up&)
|
|
|
|
{ return true; }
|
|
|
|
static bool __less(const _Tp&, const _Up&)
|
|
|
|
{ return false; }
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _T1, typename _T2, typename _T3, typename _T4, typename _T5,
|
|
|
|
typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
|
|
|
|
typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
|
|
|
|
typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
|
|
|
|
bool
|
|
|
|
operator==(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
|
|
|
|
const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
|
|
|
|
{
|
|
|
|
typedef tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10> _Tp;
|
|
|
|
typedef tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8,_U9, _U10> _Up;
|
|
|
|
return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0,
|
|
|
|
tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _T1, typename _T2, typename _T3, typename _T4, typename _T5,
|
|
|
|
typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
|
|
|
|
typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
|
|
|
|
typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
|
|
|
|
bool
|
|
|
|
operator<(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
|
|
|
|
const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
|
|
|
|
{
|
|
|
|
typedef tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10> _Tp;
|
|
|
|
typedef tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8,_U9, _U10> _Up;
|
|
|
|
return __tuple_compare<tuple_size<_Tp>::value - tuple_size<_Tp>::value, 0,
|
|
|
|
tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _T1, typename _T2, typename _T3, typename _T4, typename _T5,
|
|
|
|
typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
|
|
|
|
typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
|
|
|
|
typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
|
|
|
|
bool
|
|
|
|
operator!=(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
|
|
|
|
const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
|
|
|
|
{ return !(__t == __u); }
|
|
|
|
|
|
|
|
template<typename _T1, typename _T2, typename _T3, typename _T4, typename _T5,
|
|
|
|
typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
|
|
|
|
typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
|
|
|
|
typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
|
|
|
|
bool
|
|
|
|
operator>(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
|
|
|
|
const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
|
|
|
|
{ return __u < __t; }
|
|
|
|
|
|
|
|
template<typename _T1, typename _T2, typename _T3, typename _T4, typename _T5,
|
|
|
|
typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
|
|
|
|
typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
|
|
|
|
typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
|
|
|
|
bool
|
|
|
|
operator<=(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
|
|
|
|
const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
|
|
|
|
{ return !(__u < __t); }
|
|
|
|
|
|
|
|
template<typename _T1, typename _T2, typename _T3, typename _T4, typename _T5,
|
|
|
|
typename _T6, typename _T7, typename _T8, typename _T9, typename _T10,
|
|
|
|
typename _U1, typename _U2, typename _U3, typename _U4, typename _U5,
|
|
|
|
typename _U6, typename _U7, typename _U8, typename _U9, typename _U10>
|
|
|
|
bool
|
|
|
|
operator>=(const tuple<_T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10>& __t,
|
|
|
|
const tuple<_U1, _U2, _U3, _U4, _U5, _U6, _U7, _U8, _U9, _U10>& __u)
|
|
|
|
{ return !(__t < __u); }
|
|
|
|
|
|
|
|
// Helper which adds a reference to a type when given a reference_wrapper
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __strip_reference_wrapper
|
|
|
|
{
|
|
|
|
typedef _Tp __type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __strip_reference_wrapper<reference_wrapper<_Tp> >
|
|
|
|
{
|
|
|
|
typedef _Tp& __type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __strip_reference_wrapper<const reference_wrapper<_Tp> >
|
|
|
|
{
|
|
|
|
typedef _Tp& __type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp0 = _NullClass, typename _Tp1 = _NullClass,
|
|
|
|
typename _Tp2 = _NullClass, typename _Tp3 = _NullClass,
|
|
|
|
typename _Tp4 = _NullClass, typename _Tp5 = _NullClass,
|
|
|
|
typename _Tp6 = _NullClass, typename _Tp7 = _NullClass,
|
|
|
|
typename _Tp8 = _NullClass, typename _Tp9 = _NullClass>
|
|
|
|
struct __stripped_tuple_type
|
|
|
|
{
|
|
|
|
typedef tuple<typename __strip_reference_wrapper<_Tp0>::__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;
|
|
|
|
};
|
|
|
|
|
|
|
|
// A class (and instance) which can be used in 'tie' when an element
|
|
|
|
// of a tuple is not required
|
|
|
|
struct swallow_assign
|
|
|
|
{
|
|
|
|
template<class T>
|
|
|
|
swallow_assign&
|
|
|
|
operator=(const T&)
|
|
|
|
{ return *this; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Put this in some kind of shared file.
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
swallow_assign ignore;
|
2006-09-04 17:41:18 +02:00
|
|
|
}; // anonymous namespace
|
2005-04-01 05:35:59 +02:00
|
|
|
|
|
|
|
#define _GLIBCXX_CAT(x,y) _GLIBCXX_CAT2(x,y)
|
|
|
|
#define _GLIBCXX_CAT2(x,y) x##y
|
|
|
|
#define _SHORT_REPEAT
|
|
|
|
#define _GLIBCXX_REPEAT_HEADER <tr1/tuple_iterate.h>
|
|
|
|
#include <tr1/repeat.h>
|
|
|
|
#undef _GLIBCXX_REPEAT_HEADER
|
|
|
|
#undef _SHORT_REPEAT
|
2005-12-19 01:56:05 +01:00
|
|
|
|
|
|
|
_GLIBCXX_END_NAMESPACE
|
2004-10-25 21:05:58 +02:00
|
|
|
}
|
|
|
|
|
2005-04-01 05:35:59 +02:00
|
|
|
#include <tr1/functional>
|
2004-10-28 23:18:56 +02:00
|
|
|
|
2005-04-01 05:35:59 +02:00
|
|
|
#endif
|