From 9fdcbf40319a526845c586ac2ca147bb5ee53286 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 16 Jun 2009 21:24:41 +0000 Subject: [PATCH] exception_ptr.h (exception_ptr::swap(exception_ptr&&)): Remove. 2009-06-16 Jonathan Wakely * 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. From-SVN: r148555 --- libstdc++-v3/ChangeLog | 8 ++++ libstdc++-v3/libsupc++/exception_ptr.h | 12 +----- .../testsuite/18_support/exception_ptr/move.cc | 45 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 libstdc++-v3/testsuite/18_support/exception_ptr/move.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7d17880..03c0110 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2009-06-16 Jonathan Wakely + * 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 + * include/std/thread (~thread(), operator=(thread&&)): Call terminate if joinable. diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 37f3132..23477c9 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -123,7 +123,7 @@ namespace std exception_ptr& operator=(exception_ptr&& __o) throw() { - exception_ptr(__o).swap(*this); + exception_ptr(static_cast(__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 index 0000000..ce97bc2 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc @@ -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 +// . + +#include +#include +#include + +// 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; +} -- 2.7.4