OSDN Git Service

2008-06-22 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 22 Jun 2008 13:57:06 +0000 (13:57 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 22 Jun 2008 13:57:06 +0000 (13:57 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137012 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/doc/xml/manual/intro.xml
libstdc++-v3/include/bits/algorithmfwd.h
libstdc++-v3/include/bits/move.h
libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc

index dc39a51..26b94e5 100644 (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.
index fb23f3d..1176fd6 100644 (file)
     <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>
index 116e0b2..b4d2ee7 100644 (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);
index ab5b494..d3b5d68 100644 (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
 // 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 (file)
index 0000000..d0e99d2
--- /dev/null
@@ -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);
+}