From: Paolo Carlini Date: Fri, 13 Jun 2008 07:35:22 +0000 (+0000) Subject: array (array<>::assign): Do not define in C++0x mode, per DR 776... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6a4533e55451309198c5d36558a4b875b5555c88;p=gcc.git array (array<>::assign): Do not define in C++0x mode, per DR 776... 2008-06-13 Paolo Carlini * include/tr1_impl/array (array<>::assign): Do not define in C++0x mode, per DR 776... (array<>::fill): ... define instead. * doc/xml/manual/intro.xml: Add an entry for DR 776. * testsuite/23_containers/array/requirements/fill.cc: New. From-SVN: r136741 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 933bff852f3..2d1681c5646 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2008-06-13 Paolo Carlini + + * include/tr1_impl/array (array<>::assign): Do not define in + C++0x mode, per DR 776... + (array<>::fill): ... define instead. + * doc/xml/manual/intro.xml: Add an entry for DR 776. + * testsuite/23_containers/array/requirements/fill.cc: New. + 2008-06-12 Paolo Carlini * include/std/complex (pow(const complex<>&, int)): Do not define in diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index e30e81dcbfe..fb23f3dd603 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -666,8 +666,15 @@ Implement the int -> size_t replacements. + 776: + Undescribed assign function of std::array + + In C++0x mode, remove assign, add fill. + + 778: - std::bitset does not have any constructor taking a string literal + std::bitset does not have any constructor taking a string + literal Add it. diff --git a/libstdc++-v3/include/tr1_impl/array b/libstdc++-v3/include/tr1_impl/array index a9047438843..66dc9a2c8ce 100644 --- a/libstdc++-v3/include/tr1_impl/array +++ b/libstdc++-v3/include/tr1_impl/array @@ -56,11 +56,16 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 // No explicit construct/copy/destroy for aggregate type. - void + void +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + // DR 776. + fill(const value_type& __u) +#else assign(const value_type& __u) +#endif { std::fill_n(begin(), size(), __u); } - void + void swap(array& __other) { std::swap_ranges(begin(), end(), __other.begin()); } @@ -74,7 +79,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 { return const_iterator(&_M_instance[0]); } iterator - end() + end() { return iterator(&_M_instance[_Nm]); } const_iterator diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/fill.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/fill.cc new file mode 100644 index 00000000000..45b81b66d6c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/array/requirements/fill.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-13 Paolo Carlini +// +// Copyright (C) 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 +// 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 +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +// DR 776. Undescribed assign function of std::array. +void test01() +{ + bool test __attribute__((unused)) = true; + + const size_t len = 3; + typedef std::array array_type; + + array_type a = { { 0, 1, 2 } }; + const int value = 5; + + a.fill(value); + VERIFY( a[0] == value ); + VERIFY( a[1] == value ); + VERIFY( a[2] == value ); +} + +int main() +{ + test01(); + return 0; +}