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
This commit is contained in:
Paolo Carlini 2008-06-22 13:57:06 +00:00 committed by Paolo Carlini
parent 404013583b
commit caa8b3c687
6 changed files with 93 additions and 7 deletions

View File

@ -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.

View File

@ -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>

View File

@ -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);

View File

@ -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 */

View File

@ -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);
}

View File

@ -1,4 +1,3 @@
// { dg-do compile }
// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com>