tuple: Replace int -> size_t throughout per DR 775.
2008-05-23 Paolo Carlini <paolo.carlini@oracle.com> * include/std/tuple: Replace int -> size_t throughout per DR 775. * include/tr1_impl/array: Likewise. * include/tr1_impl/utility: Likewise. * doc/xml/manual/intro.xml: Add an entry for DR 775. From-SVN: r135834
This commit is contained in:
parent
fbcfcb3cc3
commit
740508bee2
|
@ -1,3 +1,10 @@
|
|||
2008-05-23 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/std/tuple: Replace int -> size_t throughout per DR 775.
|
||||
* include/tr1_impl/array: Likewise.
|
||||
* include/tr1_impl/utility: Likewise.
|
||||
* doc/xml/manual/intro.xml: Add an entry for DR 775.
|
||||
|
||||
2008-05-23 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* doc/xml/manual/intro.xml: Adjust links to ISO documents.
|
||||
|
|
|
@ -635,6 +635,12 @@
|
|||
<listitem><para>In C++0x mode, add at() and at() const.
|
||||
</para></listitem></varlistentry>
|
||||
|
||||
<varlistentry><term><ulink url="../ext/lwg-active.html#775">775</ulink>:
|
||||
<emphasis>Tuple indexing should be unsigned?</emphasis>
|
||||
</term>
|
||||
<listitem><para>Implement the int -> size_t replacements.
|
||||
</para></listitem></varlistentry>
|
||||
|
||||
<varlistentry><term><ulink url="../ext/lwg-active.html#778">778</ulink>:
|
||||
<emphasis>std::bitset does not have any constructor taking a string literal</emphasis>
|
||||
</term>
|
||||
|
|
|
@ -62,10 +62,10 @@ namespace std
|
|||
struct __add_ref<_Tp&>
|
||||
{ typedef _Tp& type; };
|
||||
|
||||
template<int _Idx, typename _Head, bool _IsEmpty>
|
||||
template<std::size_t _Idx, typename _Head, bool _IsEmpty>
|
||||
struct _Head_base;
|
||||
|
||||
template<int _Idx, typename _Head>
|
||||
template<std::size_t _Idx, typename _Head>
|
||||
struct _Head_base<_Idx, _Head, true>
|
||||
: public _Head
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ namespace std
|
|||
const _Head& _M_head() const { return *this; }
|
||||
};
|
||||
|
||||
template<int _Idx, typename _Head>
|
||||
template<std::size_t _Idx, typename _Head>
|
||||
struct _Head_base<_Idx, _Head, false>
|
||||
{
|
||||
_Head_base()
|
||||
|
@ -110,14 +110,14 @@ namespace std
|
|||
* point in the hierarchy; we use it to implement a constant-time
|
||||
* get() operation.
|
||||
*/
|
||||
template<int _Idx, typename... _Elements>
|
||||
template<std::size_t _Idx, typename... _Elements>
|
||||
struct _Tuple_impl;
|
||||
|
||||
/**
|
||||
* Zero-element tuple implementation. This is the basis case for the
|
||||
* inheritance recursion.
|
||||
*/
|
||||
template<int _Idx>
|
||||
template<std::size_t _Idx>
|
||||
struct _Tuple_impl<_Idx> { };
|
||||
|
||||
/**
|
||||
|
@ -125,7 +125,7 @@ namespace std
|
|||
* and derive from a @c Tuple_impl containing the remaining elements
|
||||
* (which contains the @c Tail).
|
||||
*/
|
||||
template<int _Idx, typename _Head, typename... _Tail>
|
||||
template<std::size_t _Idx, typename _Head, typename... _Tail>
|
||||
struct _Tuple_impl<_Idx, _Head, _Tail...>
|
||||
: public _Tuple_impl<_Idx + 1, _Tail...>,
|
||||
private _Head_base<_Idx, _Head, std::is_empty<_Head>::value>
|
||||
|
@ -372,14 +372,14 @@ namespace std
|
|||
|
||||
|
||||
/// Gives the type of the ith element of a given tuple type.
|
||||
template<int __i, typename _Tp>
|
||||
template<std::size_t __i, typename _Tp>
|
||||
struct tuple_element;
|
||||
|
||||
/**
|
||||
* Recursive case for tuple_element: strip off the first element in
|
||||
* the tuple and retrieve the (i-1)th element of the remaining tuple.
|
||||
*/
|
||||
template<int __i, typename _Head, typename... _Tail>
|
||||
template<std::size_t __i, typename _Head, typename... _Tail>
|
||||
struct tuple_element<__i, tuple<_Head, _Tail...> >
|
||||
: tuple_element<__i - 1, tuple<_Tail...> > { };
|
||||
|
||||
|
@ -400,32 +400,32 @@ namespace std
|
|||
template<typename... _Elements>
|
||||
struct tuple_size<tuple<_Elements...> >
|
||||
{
|
||||
static const int value = sizeof...(_Elements);
|
||||
static const std::size_t value = sizeof...(_Elements);
|
||||
};
|
||||
|
||||
template<typename... _Elements>
|
||||
const int tuple_size<tuple<_Elements...> >::value;
|
||||
const std::size_t tuple_size<tuple<_Elements...> >::value;
|
||||
|
||||
template<int __i, typename _Head, typename... _Tail>
|
||||
template<std::size_t __i, typename _Head, typename... _Tail>
|
||||
inline typename __add_ref<_Head>::type
|
||||
__get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t)
|
||||
{ return __t._M_head(); }
|
||||
|
||||
template<int __i, typename _Head, typename... _Tail>
|
||||
template<std::size_t __i, typename _Head, typename... _Tail>
|
||||
inline typename __add_c_ref<_Head>::type
|
||||
__get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t)
|
||||
{ return __t._M_head(); }
|
||||
|
||||
// Return a reference (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... _Elements>
|
||||
template<std::size_t __i, typename... _Elements>
|
||||
inline typename __add_ref<
|
||||
typename tuple_element<__i, tuple<_Elements...> >::type
|
||||
>::type
|
||||
get(tuple<_Elements...>& __t)
|
||||
{ return __get_helper<__i>(__t); }
|
||||
|
||||
template<int __i, typename... _Elements>
|
||||
template<std::size_t __i, typename... _Elements>
|
||||
inline typename __add_c_ref<
|
||||
typename tuple_element<__i, tuple<_Elements...> >::type
|
||||
>::type
|
||||
|
@ -433,28 +433,28 @@ namespace std
|
|||
{ return __get_helper<__i>(__t); }
|
||||
|
||||
// This class helps construct the various comparison operations on tuples
|
||||
template<int __check_equal_size, int __i, int __j,
|
||||
template<std::size_t __check_equal_size, std::size_t __i, std::size_t __j,
|
||||
typename _Tp, typename _Up>
|
||||
struct __tuple_compare;
|
||||
|
||||
template<int __i, int __j, typename _Tp, typename _Up>
|
||||
template<std::size_t __i, std::size_t __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));
|
||||
__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));
|
||||
__tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u));
|
||||
}
|
||||
};
|
||||
|
||||
template<int __i, typename _Tp, typename _Up>
|
||||
template<std::size_t __i, typename _Tp, typename _Up>
|
||||
struct __tuple_compare<0, __i, __i, _Tp, _Up>
|
||||
{
|
||||
static bool __eq(const _Tp&, const _Up&)
|
||||
|
@ -520,12 +520,13 @@ namespace std
|
|||
return __result_type(std::forward<_Elements>(__args)...);
|
||||
}
|
||||
|
||||
template<int...> struct __index_holder { };
|
||||
template<std::size_t...> struct __index_holder { };
|
||||
|
||||
template<int __i, typename _IdxHolder, typename... _Elements>
|
||||
template<std::size_t __i, typename _IdxHolder, typename... _Elements>
|
||||
struct __index_holder_impl;
|
||||
|
||||
template<int __i, int... _Indexes, typename _IdxHolder, typename... _Elements>
|
||||
template<std::size_t __i, std::size_t... _Indexes, typename _IdxHolder,
|
||||
typename... _Elements>
|
||||
struct __index_holder_impl<__i, __index_holder<_Indexes...>,
|
||||
_IdxHolder, _Elements...>
|
||||
{
|
||||
|
@ -534,7 +535,7 @@ namespace std
|
|||
_Elements...>::type type;
|
||||
};
|
||||
|
||||
template<int __i, int... _Indexes>
|
||||
template<std::size_t __i, std::size_t... _Indexes>
|
||||
struct __index_holder_impl<__i, __index_holder<_Indexes...> >
|
||||
{ typedef __index_holder<_Indexes...> type; };
|
||||
|
||||
|
@ -542,8 +543,8 @@ namespace std
|
|||
struct __make_index_holder
|
||||
: __index_holder_impl<0, __index_holder<>, _Elements...> { };
|
||||
|
||||
template<typename... _TElements, int... _TIdx,
|
||||
typename... _UElements, int... _UIdx>
|
||||
template<typename... _TElements, std::size_t... _TIdx,
|
||||
typename... _UElements, std::size_t... _UIdx>
|
||||
inline tuple<_TElements..., _UElements...>
|
||||
__tuple_cat_helper(const tuple<_TElements...>& __t,
|
||||
const __index_holder<_TIdx...>&,
|
||||
|
@ -552,8 +553,8 @@ namespace std
|
|||
{ return tuple<_TElements..., _UElements...>(get<_TIdx>(__t)...,
|
||||
get<_UIdx>(__u)...); }
|
||||
|
||||
template<typename... _TElements, int... _TIdx,
|
||||
typename... _UElements, int... _UIdx>
|
||||
template<typename... _TElements, std::size_t... _TIdx,
|
||||
typename... _UElements, std::size_t... _UIdx>
|
||||
inline tuple<_TElements..., _UElements...>
|
||||
__tuple_cat_helper(tuple<_TElements...>&& __t,
|
||||
const __index_holder<_TIdx...>&,
|
||||
|
@ -562,8 +563,8 @@ namespace std
|
|||
{ return tuple<_TElements..., _UElements...>
|
||||
(std::move(get<_TIdx>(__t))..., get<_UIdx>(__u)...); }
|
||||
|
||||
template<typename... _TElements, int... _TIdx,
|
||||
typename... _UElements, int... _UIdx>
|
||||
template<typename... _TElements, std::size_t... _TIdx,
|
||||
typename... _UElements, std::size_t... _UIdx>
|
||||
inline tuple<_TElements..., _UElements...>
|
||||
__tuple_cat_helper(const tuple<_TElements...>& __t,
|
||||
const __index_holder<_TIdx...>&,
|
||||
|
@ -572,8 +573,8 @@ namespace std
|
|||
{ return tuple<_TElements..., _UElements...>
|
||||
(get<_TIdx>(__t)..., std::move(get<_UIdx>(__u))...); }
|
||||
|
||||
template<typename... _TElements, int... _TIdx,
|
||||
typename... _UElements, int... _UIdx>
|
||||
template<typename... _TElements, std::size_t... _TIdx,
|
||||
typename... _UElements, std::size_t... _UIdx>
|
||||
inline tuple<_TElements..., _UElements...>
|
||||
__tuple_cat_helper(tuple<_TElements...>&& __t,
|
||||
const __index_holder<_TIdx...>&,
|
||||
|
@ -585,7 +586,7 @@ namespace std
|
|||
template<typename... _TElements, typename... _UElements>
|
||||
inline tuple<_TElements..., _UElements...>
|
||||
tuple_cat(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u)
|
||||
{
|
||||
{
|
||||
return __tuple_cat_helper(__t, typename
|
||||
__make_index_holder<_TElements...>::type(),
|
||||
__u, typename
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// class template array -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2007, 2008 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
|
||||
|
@ -222,26 +222,51 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
|||
class tuple_size;
|
||||
|
||||
/// tuple_element
|
||||
template<int _Int, typename _Tp>
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, typename _Tp>
|
||||
#else
|
||||
template<int _Int, typename _Tp>
|
||||
#endif
|
||||
class tuple_element;
|
||||
|
||||
template<typename _Tp, std::size_t _Nm>
|
||||
struct tuple_size<array<_Tp, _Nm> >
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
{ static const std::size_t value = _Nm; };
|
||||
#else
|
||||
{ static const int value = _Nm; };
|
||||
#endif
|
||||
|
||||
template<typename _Tp, std::size_t _Nm>
|
||||
const int tuple_size<array<_Tp, _Nm> >::value;
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
const std::size_t
|
||||
#else
|
||||
const int
|
||||
#endif
|
||||
tuple_size<array<_Tp, _Nm> >::value;
|
||||
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
||||
#else
|
||||
template<int _Int, typename _Tp, std::size_t _Nm>
|
||||
#endif
|
||||
struct tuple_element<_Int, array<_Tp, _Nm> >
|
||||
{ typedef _Tp type; };
|
||||
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
||||
#else
|
||||
template<int _Int, typename _Tp, std::size_t _Nm>
|
||||
#endif
|
||||
inline _Tp&
|
||||
get(array<_Tp, _Nm>& __arr)
|
||||
{ return __arr[_Int]; }
|
||||
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
||||
#else
|
||||
template<int _Int, typename _Tp, std::size_t _Nm>
|
||||
#endif
|
||||
inline const _Tp&
|
||||
get(const array<_Tp, _Nm>& __arr)
|
||||
{ return __arr[_Int]; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
// TR1 utility -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2007, 2008 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
|
||||
|
@ -37,16 +36,32 @@ namespace std
|
|||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
|
||||
template<class _Tp> class tuple_size;
|
||||
template<int _Int, class _Tp> class tuple_element;
|
||||
template<class _Tp>
|
||||
class tuple_size;
|
||||
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, class _Tp>
|
||||
#else
|
||||
template<int _Int, class _Tp>
|
||||
#endif
|
||||
class tuple_element;
|
||||
|
||||
// Various functions which give std::pair a tuple-like interface.
|
||||
template<class _Tp1, class _Tp2>
|
||||
struct tuple_size<std::pair<_Tp1, _Tp2> >
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
{ static const std::size_t value = 2; };
|
||||
#else
|
||||
{ static const int value = 2; };
|
||||
#endif
|
||||
|
||||
template<class _Tp1, class _Tp2>
|
||||
const int tuple_size<std::pair<_Tp1, _Tp2> >::value;
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
const std::size_t
|
||||
#else
|
||||
const int
|
||||
#endif
|
||||
tuple_size<std::pair<_Tp1, _Tp2> >::value;
|
||||
|
||||
template<class _Tp1, class _Tp2>
|
||||
struct tuple_element<0, std::pair<_Tp1, _Tp2> >
|
||||
|
@ -55,9 +70,13 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
|||
template<class _Tp1, class _Tp2>
|
||||
struct tuple_element<1, std::pair<_Tp1, _Tp2> >
|
||||
{ typedef _Tp2 type; };
|
||||
|
||||
|
||||
template<int _Int> struct __pair_get;
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int>
|
||||
#else
|
||||
template<int _Int>
|
||||
#endif
|
||||
struct __pair_get;
|
||||
|
||||
template<>
|
||||
struct __pair_get<0>
|
||||
|
@ -83,15 +102,23 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
|||
{ return __pair.second; }
|
||||
};
|
||||
|
||||
template<int _Int, class _Tp1, class _Tp2>
|
||||
inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
|
||||
get(std::pair<_Tp1, _Tp2>& __in)
|
||||
{ return __pair_get<_Int>::__get(__in); }
|
||||
|
||||
template<int _Int, class _Tp1, class _Tp2>
|
||||
inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
|
||||
get(const std::pair<_Tp1, _Tp2>& __in)
|
||||
{ return __pair_get<_Int>::__const_get(__in); }
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, class _Tp1, class _Tp2>
|
||||
#else
|
||||
template<int _Int, class _Tp1, class _Tp2>
|
||||
#endif
|
||||
inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
|
||||
get(std::pair<_Tp1, _Tp2>& __in)
|
||||
{ return __pair_get<_Int>::__get(__in); }
|
||||
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
template<std::size_t _Int, class _Tp1, class _Tp2>
|
||||
#else
|
||||
template<int _Int, class _Tp1, class _Tp2>
|
||||
#endif
|
||||
inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&
|
||||
get(const std::pair<_Tp1, _Tp2>& __in)
|
||||
{ return __pair_get<_Int>::__const_get(__in); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_TR1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue