mirror of git://gcc.gnu.org/git/gcc.git
tuple (tuple_element<__i, [...]): Add.
2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> * include/std/tuple (tuple_element<__i, const _Tp>, tuple_element<__i, volatile _Tp>, tuple_element<__i, const volatile _Tp>, tuple_size<const _Tp>, tuple_size<volatile _Tp>, tuple_size<const volatile _Tp>): Add. * include/std/utility (tuple_size<std::pair<_Tp1, _Tp2>>): Tweak. * include/std/array (tuple_size<array<_Tp, _Nm>>): Likewise. * testsuite/20_util/tuple/cv_tuple_size.cc: New. * testsuite/20_util/tuple/cv_tuple_element.cc: Likewise. * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Tweak dg-warning line number. From-SVN: r173919
This commit is contained in:
parent
173f26ae56
commit
664e12c126
|
|
@ -1,3 +1,16 @@
|
||||||
|
2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/std/tuple (tuple_element<__i, const _Tp>,
|
||||||
|
tuple_element<__i, volatile _Tp>, tuple_element<__i,
|
||||||
|
const volatile _Tp>, tuple_size<const _Tp>, tuple_size<volatile _Tp>,
|
||||||
|
tuple_size<const volatile _Tp>): Add.
|
||||||
|
* include/std/utility (tuple_size<std::pair<_Tp1, _Tp2>>): Tweak.
|
||||||
|
* include/std/array (tuple_size<array<_Tp, _Nm>>): Likewise.
|
||||||
|
* testsuite/20_util/tuple/cv_tuple_size.cc: New.
|
||||||
|
* testsuite/20_util/tuple/cv_tuple_element.cc: Likewise.
|
||||||
|
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Tweak dg-warning
|
||||||
|
line number.
|
||||||
|
|
||||||
2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
|
2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* include/std/tuple (tuple<>::operator=(tuple&&)): Specify as
|
* include/std/tuple (tuple<>::operator=(tuple&&)): Specify as
|
||||||
|
|
|
||||||
|
|
@ -242,18 +242,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
class tuple_size;
|
class tuple_size;
|
||||||
|
|
||||||
|
template<typename _Tp, std::size_t _Nm>
|
||||||
|
struct tuple_size<array<_Tp, _Nm>>
|
||||||
|
: public integral_constant<std::size_t, _Nm> { };
|
||||||
|
|
||||||
/// tuple_element
|
/// tuple_element
|
||||||
template<std::size_t _Int, typename _Tp>
|
template<std::size_t _Int, typename _Tp>
|
||||||
class tuple_element;
|
class tuple_element;
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
struct tuple_size<array<_Tp, _Nm> >
|
|
||||||
{ static const std::size_t value = _Nm; };
|
|
||||||
|
|
||||||
template<typename _Tp, std::size_t _Nm>
|
|
||||||
const std::size_t
|
|
||||||
tuple_size<array<_Tp, _Nm> >::value;
|
|
||||||
|
|
||||||
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
||||||
struct tuple_element<_Int, array<_Tp, _Nm> >
|
struct tuple_element<_Int, array<_Tp, _Nm> >
|
||||||
{ typedef _Tp type; };
|
{ typedef _Tp type; };
|
||||||
|
|
|
||||||
|
|
@ -505,19 +505,53 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
typedef _Head type;
|
typedef _Head type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<std::size_t __i, typename _Tp>
|
||||||
|
struct tuple_element<__i, const _Tp>
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
add_const<typename tuple_element<__i, _Tp>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<std::size_t __i, typename _Tp>
|
||||||
|
struct tuple_element<__i, volatile _Tp>
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
add_volatile<typename tuple_element<__i, _Tp>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<std::size_t __i, typename _Tp>
|
||||||
|
struct tuple_element<__i, const volatile _Tp>
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
add_cv<typename tuple_element<__i, _Tp>::type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
/// Finds the size of a given tuple type.
|
/// Finds the size of a given tuple type.
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
struct tuple_size;
|
struct tuple_size;
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
struct tuple_size<const _Tp>
|
||||||
|
: public integral_constant<
|
||||||
|
typename remove_cv<decltype(tuple_size<_Tp>::value)>::type,
|
||||||
|
tuple_size<_Tp>::value> { };
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
struct tuple_size<volatile _Tp>
|
||||||
|
: public integral_constant<
|
||||||
|
typename remove_cv<decltype(tuple_size<_Tp>::value)>::type,
|
||||||
|
tuple_size<_Tp>::value> { };
|
||||||
|
|
||||||
|
template<typename _Tp>
|
||||||
|
struct tuple_size<const volatile _Tp>
|
||||||
|
: public integral_constant<
|
||||||
|
typename remove_cv<decltype(tuple_size<_Tp>::value)>::type,
|
||||||
|
tuple_size<_Tp>::value> { };
|
||||||
|
|
||||||
/// class tuple_size
|
/// class tuple_size
|
||||||
template<typename... _Elements>
|
template<typename... _Elements>
|
||||||
struct tuple_size<tuple<_Elements...> >
|
struct tuple_size<tuple<_Elements...>>
|
||||||
{
|
: public integral_constant<std::size_t, sizeof...(_Elements)> { };
|
||||||
static const std::size_t value = sizeof...(_Elements);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename... _Elements>
|
|
||||||
const std::size_t tuple_size<tuple<_Elements...> >::value;
|
|
||||||
|
|
||||||
template<std::size_t __i, typename _Head, typename... _Tail>
|
template<std::size_t __i, typename _Head, typename... _Tail>
|
||||||
inline typename __add_ref<_Head>::type
|
inline typename __add_ref<_Head>::type
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
// Various functions which give std::pair a tuple-like interface.
|
// Various functions which give std::pair a tuple-like interface.
|
||||||
template<class _Tp1, class _Tp2>
|
template<class _Tp1, class _Tp2>
|
||||||
struct tuple_size<std::pair<_Tp1, _Tp2>>
|
struct tuple_size<std::pair<_Tp1, _Tp2>>
|
||||||
{ static const std::size_t value = 2; };
|
: public integral_constant<std::size_t, 2> { };
|
||||||
|
|
||||||
template<class _Tp1, class _Tp2>
|
|
||||||
const std::size_t
|
|
||||||
tuple_size<std::pair<_Tp1, _Tp2> >::value;
|
|
||||||
|
|
||||||
template<class _Tp1, class _Tp2>
|
template<class _Tp1, class _Tp2>
|
||||||
struct tuple_element<0, std::pair<_Tp1, _Tp2>>
|
struct tuple_element<0, std::pair<_Tp1, _Tp2>>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011 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 3, 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 COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Tuple
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static_assert(is_same<tuple_element<0, const tuple<double, void, int>>::type,
|
||||||
|
const double>::value, "Error");
|
||||||
|
static_assert(is_same<tuple_element<1, volatile tuple<short, void>>::type,
|
||||||
|
volatile void>::value, "Error");
|
||||||
|
static_assert(is_same<tuple_element<2, const volatile tuple<float,
|
||||||
|
char, int>>::type, const volatile int>::value, "Error");
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
// Copyright (C) 2011 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 3, 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 COPYING3. If not see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Tuple
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
VERIFY( tuple_size<const tuple<> >::value == 0 );
|
||||||
|
VERIFY( tuple_size<volatile tuple<int> >::value == 1 );
|
||||||
|
VERIFY( tuple_size<const volatile tuple<void> >::value == 1 );
|
||||||
|
|
||||||
|
typedef tuple<int, const int&, void> test_tuple1;
|
||||||
|
VERIFY( tuple_size<const test_tuple1>::value == 3 );
|
||||||
|
VERIFY( tuple_size<const volatile test_tuple1>::value == 3 );
|
||||||
|
VERIFY( tuple_size<volatile tuple<tuple<void> > >::value == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -51,7 +51,7 @@ main()
|
||||||
// { dg-warning "note" "" { target *-*-* } 485 }
|
// { dg-warning "note" "" { target *-*-* } 485 }
|
||||||
// { dg-warning "note" "" { target *-*-* } 479 }
|
// { dg-warning "note" "" { target *-*-* } 479 }
|
||||||
// { dg-warning "note" "" { target *-*-* } 469 }
|
// { dg-warning "note" "" { target *-*-* } 469 }
|
||||||
// { dg-warning "note" "" { target *-*-* } 603 }
|
// { dg-warning "note" "" { target *-*-* } 637 }
|
||||||
// { dg-warning "note" "" { target *-*-* } 1056 }
|
// { dg-warning "note" "" { target *-*-* } 1056 }
|
||||||
// { dg-warning "note" "" { target *-*-* } 1050 }
|
// { dg-warning "note" "" { target *-*-* } 1050 }
|
||||||
// { dg-warning "note" "" { target *-*-* } 342 }
|
// { dg-warning "note" "" { target *-*-* } 342 }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue