diff options
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 7 | ||||
-rw-r--r-- | src/corelib/tools/qbitarray.h | 3 | ||||
-rw-r--r-- | src/corelib/tools/qcommandlineoption.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 3 | ||||
-rw-r--r-- | src/corelib/tools/qeasingcurve.h | 3 | ||||
-rw-r--r-- | src/corelib/tools/qhash.h | 10 | ||||
-rw-r--r-- | src/corelib/tools/qringbuffer_p.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qshareddata.h | 18 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 10 | ||||
-rw-r--r-- | src/corelib/tools/qversionnumber.h | 5 |
10 files changed, 16 insertions, 51 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index f92eb78a6f..7f122b156c 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -101,12 +101,7 @@ public: other.size = 0; } - QArrayDataPointer &operator=(QArrayDataPointer &&other) noexcept - { - QArrayDataPointer moved(std::move(other)); - swap(moved); - return *this; - } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QArrayDataPointer) DataOps &operator*() noexcept { diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index 8abb69c0e6..8a1e229364 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -61,8 +61,7 @@ public: QBitArray(const QBitArray &other) : d(other.d) {} inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; } inline QBitArray(QBitArray &&other) noexcept : d(std::move(other.d)) {} - inline QBitArray &operator=(QBitArray &&other) noexcept - { qSwap(d, other.d); return *this; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QBitArray) inline void swap(QBitArray &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h index 6de9a31aea..2e7d8fd9da 100644 --- a/src/corelib/tools/qcommandlineoption.h +++ b/src/corelib/tools/qcommandlineoption.h @@ -72,7 +72,7 @@ public: ~QCommandLineOption(); QCommandLineOption &operator=(const QCommandLineOption &other); - QCommandLineOption &operator=(QCommandLineOption &&other) noexcept { swap(other); return *this; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCommandLineOption) void swap(QCommandLineOption &other) noexcept { qSwap(d, other.d); } diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 79f5e3fdb6..5e1eb17658 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -94,8 +94,7 @@ public: inline bool isDetached() const { return d->ref.loadRelaxed() == 1; } QContiguousCache<T> &operator=(const QContiguousCache<T> &other); - inline QContiguousCache<T> &operator=(QContiguousCache<T> &&other) noexcept - { qSwap(d, other.d); return *this; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QContiguousCache) inline void swap(QContiguousCache<T> &other) noexcept { qSwap(d, other.d); } template <typename U = T> diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index e6ee7b56d5..93aec81aa0 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -80,8 +80,7 @@ public: QEasingCurve &operator=(const QEasingCurve &other) { if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; } QEasingCurve(QEasingCurve &&other) noexcept : d_ptr(other.d_ptr) { other.d_ptr = nullptr; } - QEasingCurve &operator=(QEasingCurve &&other) noexcept - { qSwap(d_ptr, other.d_ptr); return *this; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QEasingCurve) void swap(QEasingCurve &other) noexcept { qSwap(d_ptr, other.d_ptr); } diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 2b1b155efb..a1c1371e24 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -750,15 +750,7 @@ public: : d(std::exchange(other.d, nullptr)) { } - QHash &operator=(QHash &&other) noexcept(std::is_nothrow_destructible<Node>::value) - { - if (d != other.d) { - if (d && !d->ref.deref()) - delete d; - d = std::exchange(other.d, nullptr); - } - return *this; - } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QHash) #ifdef Q_QDOC template <typename InputIterator> QHash(InputIterator f, InputIterator l); diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 85a3882a3c..2cd6dd0756 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -94,11 +94,7 @@ public: { other.headOffset = other.tailOffset = 0; } - inline QRingChunk &operator=(QRingChunk &&other) noexcept - { - swap(other); - return *this; - } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QRingChunk) inline void swap(QRingChunk &other) noexcept { diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 85078670e9..71f2e17799 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -111,13 +111,8 @@ public: } return *this; } - QSharedDataPointer(QSharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } - inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other) noexcept - { - QSharedDataPointer moved(std::move(other)); - swap(moved); - return *this; - } + QSharedDataPointer(QSharedDataPointer &&o) noexcept : d(qExchange(o.d, nullptr)) {} + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSharedDataPointer) inline bool operator!() const { return !d; } @@ -216,13 +211,8 @@ public: } return *this; } - inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) noexcept : d(o.d) { o.d = nullptr; } - inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other) noexcept - { - QExplicitlySharedDataPointer moved(std::move(other)); - swap(moved); - return *this; - } + inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) noexcept : d(qExchange(o.d, nullptr)) {} + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QExplicitlySharedDataPointer) inline bool operator!() const { return !d; } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 30bccb66a4..2e7ec8103c 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -333,12 +333,7 @@ public: other.d = nullptr; other.value = nullptr; } - QSharedPointer &operator=(QSharedPointer &&other) noexcept - { - QSharedPointer moved(std::move(other)); - swap(moved); - return *this; - } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSharedPointer) template <class X, IfCompatible<X> = true> QSharedPointer(QSharedPointer<X> &&other) noexcept @@ -563,8 +558,7 @@ public: other.d = nullptr; other.value = nullptr; } - QWeakPointer &operator=(QWeakPointer &&other) noexcept - { QWeakPointer moved(std::move(other)); swap(moved); return *this; } + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QWeakPointer) QWeakPointer &operator=(const QWeakPointer &other) noexcept { QWeakPointer copy(other); diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 51d61004f6..e1d979f000 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -126,10 +126,11 @@ class QVersionNumber other.dummy = 1; } - SegmentStorage &operator=(SegmentStorage &&other) noexcept + QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(SegmentStorage) + + void swap(SegmentStorage &other) noexcept { qSwap(dummy, other.dummy); - return *this; } explicit SegmentStorage(QList<int> &&seg) |