From f815676b7d46cfe6e79985dee9fce182edb346d7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 25 Jun 2015 18:41:14 +0200 Subject: QtCore: make all Q_DECLARE_SHARED types nothrow move-assignable Excepting QDebug, which doesn't have value semantics. Change-Id: I43757ef7bba4c1f5b6de9144f12b38ce840cd9f9 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/io/qdir.h | 5 ++--- src/corelib/io/qfileinfo.h | 5 ++--- src/corelib/io/qprocess.h | 5 ++++- src/corelib/io/qstorageinfo.h | 5 ++--- src/corelib/io/qurlquery.h | 5 ++--- src/corelib/mimetypes/qmimetype.h | 8 ++------ src/corelib/tools/qcommandlineoption.h | 5 ++--- src/corelib/tools/qdatetime.h | 5 ++++- src/corelib/tools/qvector.h | 7 +++---- 9 files changed, 23 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index b6946eba65..ab3a331229 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -101,11 +101,10 @@ public: QDir &operator=(const QDir &); QDir &operator=(const QString &path); #ifdef Q_COMPILER_RVALUE_REFS - inline QDir &operator=(QDir &&other) - { qSwap(d_ptr, other.d_ptr); return *this; } + QDir &operator=(QDir &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif - inline void swap(QDir &other) + void swap(QDir &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } void setPath(const QString &path); diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index 58cf9a5c0f..59d12c3883 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -62,11 +62,10 @@ public: QFileInfo &operator=(const QFileInfo &fileinfo); #ifdef Q_COMPILER_RVALUE_REFS - inline QFileInfo&operator=(QFileInfo &&other) - { qSwap(d_ptr, other.d_ptr); return *this; } + QFileInfo &operator=(QFileInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif - inline void swap(QFileInfo &other) + void swap(QFileInfo &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } bool operator==(const QFileInfo &fileinfo) const; diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 32fa4aa866..df9fa886c1 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -60,9 +60,12 @@ public: QProcessEnvironment(); QProcessEnvironment(const QProcessEnvironment &other); ~QProcessEnvironment(); +#ifdef Q_COMPILER_RVALUE_REFS + QProcessEnvironment &operator=(QProcessEnvironment && other) Q_DECL_NOTHROW { swap(other); return *this; } +#endif QProcessEnvironment &operator=(const QProcessEnvironment &other); - inline void swap(QProcessEnvironment &other) { qSwap(d, other.d); } + void swap(QProcessEnvironment &other) Q_DECL_NOTHROW { qSwap(d, other.d); } bool operator==(const QProcessEnvironment &other) const; inline bool operator!=(const QProcessEnvironment &other) const diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h index 848278e69f..b9d694cb14 100644 --- a/src/corelib/io/qstorageinfo.h +++ b/src/corelib/io/qstorageinfo.h @@ -55,11 +55,10 @@ public: QStorageInfo &operator=(const QStorageInfo &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QStorageInfo &operator=(QStorageInfo &&other) - { qSwap(d, other.d); return *this; } + QStorageInfo &operator=(QStorageInfo &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif - inline void swap(QStorageInfo &other) + inline void swap(QStorageInfo &other) Q_DECL_NOTHROW { qSwap(d, other.d); } void setPath(const QString &path); diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index 21962fcb22..ae3a79c119 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -56,8 +56,7 @@ public: QUrlQuery(const QUrlQuery &other); QUrlQuery &operator=(const QUrlQuery &other); #ifdef Q_COMPILER_RVALUE_REFS - QUrlQuery &operator=(QUrlQuery &&other) - { qSwap(d, other.d); return *this; } + QUrlQuery &operator=(QUrlQuery &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif ~QUrlQuery(); @@ -65,7 +64,7 @@ public: bool operator!=(const QUrlQuery &other) const { return !(*this == other); } - void swap(QUrlQuery &other) { qSwap(d, other.d); } + void swap(QUrlQuery &other) Q_DECL_NOTHROW { qSwap(d, other.d); } bool isEmpty() const; bool isDetached() const; diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h index 5693b703ee..3c153da21d 100644 --- a/src/corelib/mimetypes/qmimetype.h +++ b/src/corelib/mimetypes/qmimetype.h @@ -57,13 +57,9 @@ public: QMimeType(const QMimeType &other); QMimeType &operator=(const QMimeType &other); #ifdef Q_COMPILER_RVALUE_REFS - QMimeType &operator=(QMimeType &&other) - { - qSwap(d, other.d); - return *this; - } + QMimeType &operator=(QMimeType &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif - void swap(QMimeType &other) + void swap(QMimeType &other) Q_DECL_NOTHROW { qSwap(d, other.d); } diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h index 85fc5ca6dd..828522cbc5 100644 --- a/src/corelib/tools/qcommandlineoption.h +++ b/src/corelib/tools/qcommandlineoption.h @@ -58,11 +58,10 @@ public: QCommandLineOption &operator=(const QCommandLineOption &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QCommandLineOption &operator=(QCommandLineOption &&other) - { qSwap(d, other.d); return *this; } + QCommandLineOption &operator=(QCommandLineOption &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif - inline void swap(QCommandLineOption &other) + void swap(QCommandLineOption &other) Q_DECL_NOTHROW { qSwap(d, other.d); } QStringList names() const; diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 78ec2b156a..273778f48c 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -222,9 +222,12 @@ public: QDateTime(const QDateTime &other); ~QDateTime(); +#ifdef Q_COMPILER_RVALUE_REFS + QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; } +#endif QDateTime &operator=(const QDateTime &other); - inline void swap(QDateTime &other) { qSwap(d, other.d); } + void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d, other.d); } bool isNull() const; bool isValid() const; diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index d13ae9dccd..821fc9b68a 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -69,11 +69,10 @@ public: inline ~QVector() { if (!d->ref.deref()) freeData(d); } QVector &operator=(const QVector &v); #ifdef Q_COMPILER_RVALUE_REFS - inline QVector(QVector &&other) : d(other.d) { other.d = Data::sharedNull(); } - inline QVector operator=(QVector &&other) - { qSwap(d, other.d); return *this; } + QVector(QVector &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } + QVector operator=(QVector &&other) Q_DECL_NOTHROW { swap(other); return *this; } #endif - inline void swap(QVector &other) { qSwap(d, other.d); } + void swap(QVector &other) Q_DECL_NOTHROW { qSwap(d, other.d); } #ifdef Q_COMPILER_INITIALIZER_LISTS inline QVector(std::initializer_list args); #endif -- cgit v1.2.3