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) <ogoffart@woboq.com>
bb10
Marc Mutz 2015-06-25 18:41:14 +02:00
parent 20147fae60
commit f815676b7d
9 changed files with 23 additions and 27 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -69,11 +69,10 @@ public:
inline ~QVector() { if (!d->ref.deref()) freeData(d); }
QVector<T> &operator=(const QVector<T> &v);
#ifdef Q_COMPILER_RVALUE_REFS
inline QVector(QVector<T> &&other) : d(other.d) { other.d = Data::sharedNull(); }
inline QVector<T> operator=(QVector<T> &&other)
{ qSwap(d, other.d); return *this; }
QVector(QVector<T> &&other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); }
QVector<T> operator=(QVector<T> &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
inline void swap(QVector<T> &other) { qSwap(d, other.d); }
void swap(QVector<T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QVector(std::initializer_list<T> args);
#endif