From 46c5b8661222e86dca9363b14a84b46f959149a8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 27 Jun 2015 13:42:13 +0200 Subject: [PATCH] QSharedPointer: add move construction, assignment from compatible shared pointers Change-Id: I772c568055c9bed6eb627ad35dba300925fc0fde Reviewed-by: Thiago Macieira --- src/corelib/tools/qsharedpointer_impl.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 80b1501d1c..b1434b530e 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -336,6 +336,23 @@ public: swap(moved); return *this; } + + template + QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW + : value(other.value), d(other.d) + { + other.d = Q_NULLPTR; + other.value = Q_NULLPTR; + } + + template + QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW + { + QSharedPointer moved(std::move(other)); + swap(moved); + return *this; + } + #endif template