Index: include/std/tuple =================================================================== --- include/std/tuple (revision 173917) +++ include/std/tuple (working copy) @@ -505,20 +505,54 @@ 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; + 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 - struct tuple_size > - { - static const std::size_t value = sizeof...(_Elements); - }; + struct tuple_size> + : public integral_constant { }; - template - const std::size_t tuple_size >::value; - template inline typename __add_ref<_Head>::type __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept Index: include/std/utility =================================================================== --- include/std/utility (revision 173917) +++ include/std/utility (working copy) @@ -88,13 +88,9 @@ // Various functions which give std::pair a tuple-like interface. template struct tuple_size> - { static const std::size_t value = 2; }; + : public integral_constant { }; template - const std::size_t - tuple_size >::value; - - template struct tuple_element<0, std::pair<_Tp1, _Tp2>> { typedef _Tp1 type; }; Index: include/std/array =================================================================== --- include/std/array (revision 173917) +++ include/std/array (working copy) @@ -242,18 +242,14 @@ 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; }; Index: testsuite/20_util/tuple/cv_tuple_size.cc =================================================================== --- testsuite/20_util/tuple/cv_tuple_size.cc (revision 0) +++ testsuite/20_util/tuple/cv_tuple_size.cc (revision 0) @@ -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; +} Index: testsuite/20_util/tuple/cv_tuple_element.cc =================================================================== --- testsuite/20_util/tuple/cv_tuple_element.cc (revision 0) +++ testsuite/20_util/tuple/cv_tuple_element.cc (revision 0) @@ -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"); Index: testsuite/20_util/weak_ptr/comparison/cmp_neg.cc =================================================================== --- testsuite/20_util/weak_ptr/comparison/cmp_neg.cc (revision 173917) +++ testsuite/20_util/weak_ptr/comparison/cmp_neg.cc (working copy) @@ -51,7 +51,7 @@ // { 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 }