QString/QByteArray: = default the move ctors

Instead of relying on implicit construction of the d-pointer and then
swapping that with other.d (using overly-generic qSwap(), no less),
simply let the compiler do The Right Thing™ via QArrayDataPointer's
move constructor.

Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I3be30f99f6fb0e17d3550edbe64cbe80880e604a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2022-03-15 15:34:39 +01:00
parent 156afbc9b8
commit 78891e5390
2 changed files with 2 additions and 2 deletions

View File

@ -121,7 +121,7 @@ public:
QByteArray &operator=(const QByteArray &) noexcept;
QByteArray &operator=(const char *str);
inline QByteArray(QByteArray && other) noexcept
{ qSwap(d, other.d); }
= default;
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QByteArray)
inline void swap(QByteArray &other) noexcept
{ d.swap(other.d); }

View File

@ -462,7 +462,7 @@ public:
QString &operator=(const QString &) noexcept;
QString &operator=(QLatin1String latin1);
inline QString(QString &&other) noexcept
{ qSwap(d, other.d); }
= default;
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString)
void swap(QString &other) noexcept { d.swap(other.d); }
inline qsizetype size() const { return d.size; }