diff options
-rw-r--r-- | src/corelib/serialization/qcborvalue.h | 5 | ||||
-rw-r--r-- | tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index f7064ac6e1..aa51e5da81 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -188,9 +188,8 @@ public: QCborValue &operator=(const QCborValue &other); QCborValue &operator=(QCborValue &&other) noexcept { - QCborValue tmp; - qSwap(*this, tmp); - qSwap(other, *this); + QCborValue tmp(std::move(other)); + swap(tmp); return *this; } diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 05cf199abe..64321c11fa 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -385,9 +385,21 @@ void tst_QCborValue::copyCompare() { QFETCH(QCborValue, v); QCborValue other = v; + + // self-moving + v = std::move(v); + QCOMPARE(v, other); // make sure it's still valid + + // moving + v = std::move(other); + other = std::move(v); + + // normal copying + other = v; other = v; v = other; + QCOMPARE(v.compare(other), 0); QCOMPARE(v, other); QVERIFY(!(v != other)); |