From: paolo Date: Thu, 19 May 2011 20:48:39 +0000 (+0000) Subject: 2011-05-19 Paolo Carlini X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=462625258ca6dbd472878fe3717c8ddd8113bf28 2011-05-19 Paolo Carlini * include/std/tuple (tuple_element<__i, const _Tp>, tuple_element<__i, volatile _Tp>, tuple_element<__i, const volatile _Tp>, tuple_size, tuple_size, tuple_size): Add. * include/std/utility (tuple_size>): Tweak. * include/std/array (tuple_size>): 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173919 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6275373d9f5..f6b9159d235 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,18 @@ 2011-05-19 Paolo Carlini + * include/std/tuple (tuple_element<__i, const _Tp>, + tuple_element<__i, volatile _Tp>, tuple_element<__i, + const volatile _Tp>, tuple_size, tuple_size, + tuple_size): Add. + * include/std/utility (tuple_size>): Tweak. + * include/std/array (tuple_size>): 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 + * include/std/tuple (tuple<>::operator=(tuple&&)): Specify as noexcept. (__get_helper): Likewise. diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index b0fc75b14bc..474b884ecb5 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -242,18 +242,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template class tuple_size; + template + struct tuple_size> + : public integral_constant { }; + /// tuple_element template class tuple_element; - template - struct tuple_size > - { static const std::size_t value = _Nm; }; - - template - const std::size_t - tuple_size >::value; - template struct tuple_element<_Int, array<_Tp, _Nm> > { typedef _Tp type; }; diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 682e3c92a47..dc9330d0b59 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -505,19 +505,53 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef _Head type; }; + template + struct tuple_element<__i, const _Tp> + { + typedef typename + add_const::type>::type type; + }; + + template + struct tuple_element<__i, volatile _Tp> + { + typedef typename + add_volatile::type>::type type; + }; + + template + struct tuple_element<__i, const volatile _Tp> + { + typedef typename + add_cv::type>::type type; + }; + /// Finds the size of a given tuple type. template struct tuple_size; - /// class tuple_size - template - struct tuple_size > - { - static const std::size_t value = sizeof...(_Elements); - }; + template + struct tuple_size + : public integral_constant< + typename remove_cv::value)>::type, + tuple_size<_Tp>::value> { }; + template + struct tuple_size + : public integral_constant< + typename remove_cv::value)>::type, + tuple_size<_Tp>::value> { }; + + template + struct tuple_size + : public integral_constant< + typename remove_cv::value)>::type, + tuple_size<_Tp>::value> { }; + + /// class tuple_size template - const std::size_t tuple_size >::value; + struct tuple_size> + : public integral_constant { }; template inline typename __add_ref<_Head>::type diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index 5c6bd03c0ea..f433e46acee 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -88,11 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Various functions which give std::pair a tuple-like interface. template struct tuple_size> - { static const std::size_t value = 2; }; - - template - const std::size_t - tuple_size >::value; + : public integral_constant { }; template struct tuple_element<0, std::pair<_Tp1, _Tp2>> diff --git a/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_element.cc b/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_element.cc new file mode 100644 index 00000000000..df4fb435e53 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_element.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-19 Paolo Carlini +// +// 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 +// . + +// Tuple + +#include + +using namespace std; + +static_assert(is_same>::type, + const double>::value, "Error"); +static_assert(is_same>::type, + volatile void>::value, "Error"); +static_assert(is_same>::type, const volatile int>::value, "Error"); diff --git a/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_size.cc b/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_size.cc new file mode 100644 index 00000000000..8224528f4df --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_size.cc @@ -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 +// . + +// Tuple + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + VERIFY( tuple_size >::value == 0 ); + VERIFY( tuple_size >::value == 1 ); + VERIFY( tuple_size >::value == 1 ); + + typedef tuple test_tuple1; + VERIFY( tuple_size::value == 3 ); + VERIFY( tuple_size::value == 3 ); + VERIFY( tuple_size > >::value == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index 24168ceda2c..d449be317ad 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -51,7 +51,7 @@ main() // { dg-warning "note" "" { target *-*-* } 485 } // { dg-warning "note" "" { target *-*-* } 479 } // { dg-warning "note" "" { target *-*-* } 469 } -// { dg-warning "note" "" { target *-*-* } 603 } +// { dg-warning "note" "" { target *-*-* } 637 } // { dg-warning "note" "" { target *-*-* } 1056 } // { dg-warning "note" "" { target *-*-* } 1050 } // { dg-warning "note" "" { target *-*-* } 342 }