From: Paolo Carlini Date: Sun, 22 Jun 2008 13:57:06 +0000 (+0000) Subject: move.h (swap(_Tp (&)[_Nm], _Tp (&)[_Nm])): Add, per DR 809. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=caa8b3c687ebe2959c5499894986e0df3d07fdb7;p=gcc.git move.h (swap(_Tp (&)[_Nm], _Tp (&)[_Nm])): Add, per DR 809. 2008-06-22 Paolo Carlini * include/bits/move.h (swap(_Tp (&)[_Nm], _Tp (&)[_Nm])): Add, per DR 809. * include/bits/algorithmfwd.h: Add. * doc/xml/manual/intro.xml: Add an entry for DR 809. * testsuite/25_algorithms/swap/dr809.cc: New. * testsuite/25_algorithms/swap/requirements/explicit_instantiation/ 2.cc: Remove stray empty line. From-SVN: r137012 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dc39a518cfb..26b94e578ec 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2008-06-22 Paolo Carlini + + * include/bits/move.h (swap(_Tp (&)[_Nm], _Tp (&)[_Nm])): Add, + per DR 809. + * include/bits/algorithmfwd.h: Add. + * doc/xml/manual/intro.xml: Add an entry for DR 809. + * testsuite/25_algorithms/swap/dr809.cc: New. + + * testsuite/25_algorithms/swap/requirements/explicit_instantiation/ + 2.cc: Remove stray empty line. + 2008-06-21 Paolo Carlini * include/bits/stl_move.h: Rename to move.h. diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index fb23f3dd603..1176fd65096 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -685,6 +685,12 @@ In C++0x mode, add std::proj. + 809: + std::swap should be overloaded for array types + + Add the overload. + + 844: complex pow return type is ambiguous diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 116e0b25e21..b4d2ee795ea 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -1,6 +1,6 @@ // declarations -*- 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 @@ -392,6 +392,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void swap(_Tp&, _Tp&); + template + void + swap(_Tp (&)[_Nm], _Tp (&)[_Nm]); + template _FIter2 swap_ranges(_FIter1, _FIter1, _FIter2); diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index ab5b494f1b9..d3b5d688ab2 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -1,6 +1,6 @@ // Move, forward and identity for C++0x + swap -*- 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 @@ -27,15 +27,16 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -/** @file stl_move.h +/** @file move.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ -#ifndef _STL_MOVE_H -#define _STL_MOVE_H 1 +#ifndef _MOVE_H +#define _MOVE_H 1 #include +#include #include #ifdef __GXX_EXPERIMENTAL_CXX0X__ @@ -87,6 +88,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __b = _GLIBCXX_MOVE(__tmp); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 809. std::swap should be overloaded for array types. + template + inline void + swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) + { + for (size_t __n = 0; __n < _Nm; ++__n) + swap(__a[__n], __b[__n]); + } + _GLIBCXX_END_NAMESPACE -#endif /* _STL_MOVE_H */ +#endif /* _MOVE_H */ diff --git a/libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc b/libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc new file mode 100644 index 00000000000..d0e99d2bc99 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc @@ -0,0 +1,55 @@ +// { dg-do compile } + +// 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. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include +#include + +template + class W + { + public: + T data; + }; + +template + void + swap(W& x, W& y) + { + using std::swap; + swap(x.data, y.data); + } + +// DR 809. std::swap should be overloaded for array types. +void test01() +{ + W w1, w2; // Two objects of a Swappable type. + + using std::swap; + swap(w1, w2); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc index 1a2ae902fe3..0b098dd7fec 100644 --- a/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc +++ b/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc @@ -1,4 +1,3 @@ - // { dg-do compile } // 2007-09-20 Benjamin Kosnik