diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2008-06-22 13:57:06 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-06-22 13:57:06 +0000 |
commit | caa8b3c687ebe2959c5499894986e0df3d07fdb7 (patch) | |
tree | b79c3afb32eb8cd0727eed65e48fb88f1d84bf90 | |
parent | 404013583b95cc5bf345667c345990b8c85e5911 (diff) | |
download | gcc-caa8b3c687ebe2959c5499894986e0df3d07fdb7.zip gcc-caa8b3c687ebe2959c5499894986e0df3d07fdb7.tar.gz gcc-caa8b3c687ebe2959c5499894986e0df3d07fdb7.tar.bz2 |
move.h (swap(_Tp (&)[_Nm], _Tp (&)[_Nm])): Add, per DR 809.
2008-06-22 Paolo Carlini <paolo.carlini@oracle.com>
* 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
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/doc/xml/manual/intro.xml | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/algorithmfwd.h | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/move.h | 21 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc | 55 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc | 1 |
6 files changed, 93 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dc39a51..26b94e5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2008-06-22 Paolo Carlini <paolo.carlini@oracle.com> + + * 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 <paolo.carlini@oracle.com> * 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 fb23f3d..1176fd6 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -685,6 +685,12 @@ <listitem><para>In C++0x mode, add std::proj. </para></listitem></varlistentry> + <varlistentry><term><ulink url="../ext/lwg-active.html#809">809</ulink>: + <emphasis>std::swap should be overloaded for array types</emphasis> + </term> + <listitem><para>Add the overload. + </para></listitem></varlistentry> + <varlistentry><term><ulink url="../ext/lwg-active.html#844">844</ulink>: <emphasis>complex pow return type is ambiguous</emphasis> </term> diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 116e0b2..b4d2ee7 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -1,6 +1,6 @@ // <algorithm> 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<typename _Tp, size_t _Nm> + void + swap(_Tp (&)[_Nm], _Tp (&)[_Nm]); + template<typename _FIter1, typename _FIter2> _FIter2 swap_ranges(_FIter1, _FIter1, _FIter2); diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index ab5b494..d3b5d68 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 <bits/c++config.h> +#include <cstddef> #include <bits/concept_check.h> #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<typename _Tp, size_t _Nm> + 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 0000000..d0e99d2 --- /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 <string> +#include <algorithm> + +template<class T> + class W + { + public: + T data; + }; + +template<class T> + void + swap(W<T>& x, W<T>& y) + { + using std::swap; + swap(x.data, y.data); + } + +// DR 809. std::swap should be overloaded for array types. +void test01() +{ + W<std::string[8]> 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 1a2ae90..0b098dd 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 <bkoz@redhat.com> |