QEasingCurve: implement move-assignment operator
authorMarc Mutz <marc.mutz@kdab.com>
Sat, 18 Feb 2012 07:52:51 +0000 (08:52 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 21 Feb 2012 14:28:40 +0000 (15:28 +0100)
Implemented as in QPen etc.

Change-Id: I65b43c6ec7308ca4b44f614594c15c41ab2f89f9
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qeasingcurve.h
tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp

index 8b2e783..33d7c69 100644 (file)
@@ -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); }
 
index d5d7dde..1d4e91d 100644 (file)
 
 #include <qeasingcurve.h>
 
+#ifdef Q_COMPILER_RVALUE_REFS // cpp11() slot
+# include <utility> // 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"