From 6a6178702e8af97b943c728f1cb4ab20233835a2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 18 Feb 2012 08:52:51 +0100 Subject: QEasingCurve: implement move-assignment operator Implemented as in QPen etc. Change-Id: I65b43c6ec7308ca4b44f614594c15c41ab2f89f9 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/tools/qeasingcurve.h | 4 ++++ .../corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index 8b2e783bdc..33d7c6934e 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -83,6 +83,10 @@ public: ~QEasingCurve(); QEasingCurve &operator=(const QEasingCurve &other); +#ifdef Q_COMPILER_RVALUE_REFS + QEasingCurve &operator=(QEasingCurve &&other) + { qSwap(d_ptr, other.d_ptr); return *this; } +#endif inline void swap(QEasingCurve &other) { qSwap(d_ptr, other.d_ptr); } diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index d5d7ddeb1d..1d4e91dc00 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -43,6 +43,10 @@ #include +#ifdef Q_COMPILER_RVALUE_REFS // cpp11() slot +# include // for std::move() +#endif + class tst_QEasingCurve : public QObject { Q_OBJECT @@ -61,6 +65,7 @@ private slots: void tcbSpline(); void testCbrtDouble(); void testCbrtFloat(); + void cpp11(); }; void tst_QEasingCurve::type() @@ -770,5 +775,19 @@ void tst_QEasingCurve::testCbrtFloat() } } +void tst_QEasingCurve::cpp11() +{ +#ifdef Q_COMPILER_RVALUE_REFS + { + QEasingCurve ec( QEasingCurve::InOutBack ); + QEasingCurve copy; + const QEasingCurve::Type type = copy.type(); + copy = std::move(ec); // move assignment op + QCOMPARE( copy.type(), QEasingCurve::InOutBack ); + QCOMPARE( ec.type(), type ); + } +#endif +} + QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" -- cgit v1.2.3