Commit caa8b3c6 by Paolo Carlini Committed by Paolo Carlini

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
parent 40401358
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> 2008-06-21 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_move.h: Rename to move.h. * include/bits/stl_move.h: Rename to move.h.
......
...@@ -685,6 +685,12 @@ ...@@ -685,6 +685,12 @@
<listitem><para>In C++0x mode, add std::proj. <listitem><para>In C++0x mode, add std::proj.
</para></listitem></varlistentry> </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>: <varlistentry><term><ulink url="../ext/lwg-active.html#844">844</ulink>:
<emphasis>complex pow return type is ambiguous</emphasis> <emphasis>complex pow return type is ambiguous</emphasis>
</term> </term>
......
// <algorithm> declarations -*- C++ -*- // <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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -392,6 +392,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -392,6 +392,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void void
swap(_Tp&, _Tp&); swap(_Tp&, _Tp&);
template<typename _Tp, size_t _Nm>
void
swap(_Tp (&)[_Nm], _Tp (&)[_Nm]);
template<typename _FIter1, typename _FIter2> template<typename _FIter1, typename _FIter2>
_FIter2 _FIter2
swap_ranges(_FIter1, _FIter1, _FIter2); swap_ranges(_FIter1, _FIter1, _FIter2);
......
// Move, forward and identity for C++0x + swap -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -27,15 +27,16 @@ ...@@ -27,15 +27,16 @@
// invalidate any other reasons why the executable file might be covered by // invalidate any other reasons why the executable file might be covered by
// the GNU General Public License. // the GNU General Public License.
/** @file stl_move.h /** @file move.h
* This is an internal header file, included by other library headers. * This is an internal header file, included by other library headers.
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
#ifndef _STL_MOVE_H #ifndef _MOVE_H
#define _STL_MOVE_H 1 #define _MOVE_H 1
#include <bits/c++config.h> #include <bits/c++config.h>
#include <cstddef>
#include <bits/concept_check.h> #include <bits/concept_check.h>
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
...@@ -87,6 +88,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -87,6 +88,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__b = _GLIBCXX_MOVE(__tmp); __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 _GLIBCXX_END_NAMESPACE
#endif /* _STL_MOVE_H */ #endif /* _MOVE_H */
// { 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);
}
// { dg-do compile } // { dg-do compile }
// 2007-09-20 Benjamin Kosnik <bkoz@redhat.com> // 2007-09-20 Benjamin Kosnik <bkoz@redhat.com>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment