OSDN Git Service

2009-06-16 Jonathan Wakely <jwakely.gcc@gmail.com>
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Jun 2009 21:24:41 +0000 (21:24 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Jun 2009 21:24:41 +0000 (21:24 +0000)
* libsupc++/exception_ptr.h (exception_ptr::swap(exception_ptr&&)):
Remove.
(exception_ptr::operator=(exception_ptr&&)): Cast source to
rvalue-reference so that move constructor is called.
* testsuite/18_support/exception_ptr/move.cc: New.

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

libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/exception_ptr.h
libstdc++-v3/testsuite/18_support/exception_ptr/move.cc [new file with mode: 0644]

index 7d17880..03c0110 100644 (file)
@@ -1,5 +1,13 @@
 2009-06-16  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
+       * libsupc++/exception_ptr.h (exception_ptr::swap(exception_ptr&&)):
+       Remove.
+       (exception_ptr::operator=(exception_ptr&&)): Cast source to
+       rvalue-reference so that move constructor is called.
+       * testsuite/18_support/exception_ptr/move.cc: New.
+
+2009-06-16  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
        * include/std/thread (~thread(), operator=(thread&&)): Call terminate
        if joinable.
 
index 37f3132..23477c9 100644 (file)
@@ -123,7 +123,7 @@ namespace std
       exception_ptr& 
       operator=(exception_ptr&& __o) throw()
       {
-        exception_ptr(__o).swap(*this);
+        exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
         return *this;
       }
 #endif
@@ -133,16 +133,6 @@ namespace std
       void 
       swap(exception_ptr&) throw();
 
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-      void 
-      swap(exception_ptr &&__o) throw()
-      {
-        void *__tmp = _M_exception_object;
-        _M_exception_object = __o._M_exception_object;
-        __o._M_exception_object = __tmp;
-      }
-#endif
-
 #ifdef _GLIBCXX_EH_PTR_COMPAT
       // Retained for compatibility with CXXABI_1.3.
       bool operator!() const throw() __attribute__ ((__pure__));
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc
new file mode 100644 (file)
index 0000000..ce97bc2
--- /dev/null
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-atomic-builtins "" }
+
+// Copyright (C) 2009 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 3, 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 COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <exception>
+#include <utility>
+#include <testsuite_hooks.h>
+
+// Verify move construction and assignment are efficient and do not copy.
+// This behaviour is a GNU extension provided for efficiency.
+void test01()
+{
+  bool test = true;
+  std::exception_ptr p1 = std::copy_exception(test);
+  std::exception_ptr p2 = std::move(p1);
+  VERIFY( p1 == 0 );
+  VERIFY( !(p2 == 0) );
+
+  p1 = std::move(p2);
+  VERIFY( !(p1 == 0) );
+  VERIFY( p2 == 0 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}