diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-07-07 10:33:28 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-07-19 10:33:59 +0000 |
commit | 74a658599f84a2548186c616405e39d1430e4f6c (patch) | |
tree | de5279aa1ddbcfa9e9722bc7993cf22a0e838c47 /src | |
parent | 5c442321220e9ba7818e2eba4fa22b159b6477ab (diff) |
QArrayDataPointer: make move semantics consistent with other containers
That is:
- nothrow default constructor
- nothrow move constructor
- nothrow move assignment operator
- nothrow swap
- as a generic container, destroy lhs contents immediately
on move-assignment.
Change-Id: I6ec2b9451d3a0ddb63a97ea84504bc7f87d8d34d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 103eb073a9..9804d2c2d5 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -46,7 +46,7 @@ private: typedef QArrayDataOps<T> DataOps; public: - QArrayDataPointer() + QArrayDataPointer() Q_DECL_NOTHROW : d(Data::sharedNull()) { } @@ -77,15 +77,16 @@ public: } #ifdef Q_COMPILER_RVALUE_REFS - QArrayDataPointer(QArrayDataPointer &&other) + QArrayDataPointer(QArrayDataPointer &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } - QArrayDataPointer &operator=(QArrayDataPointer &&other) + QArrayDataPointer &operator=(QArrayDataPointer &&other) Q_DECL_NOTHROW { - this->swap(other); + QArrayDataPointer moved(std::move(other)); + this->swap(moved); return *this; } #endif @@ -143,7 +144,7 @@ public: bool isSharable() const { return d->isSharable(); } #endif - void swap(QArrayDataPointer &other) + void swap(QArrayDataPointer &other) Q_DECL_NOTHROW { qSwap(d, other.d); } |