Add qMove macro to support std::move
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 25 Apr 2012 09:09:48 +0000 (11:09 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 20 Jun 2012 01:17:55 +0000 (03:17 +0200)
Change-Id: I373e07f479c11b172dab35ed7e5b62724aa50a1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/global/qcompilerdetection.h
src/corelib/global/qglobal.cpp
tests/auto/other/collections/tst_collections.cpp

index 8621d8b..68c8f73 100644 (file)
 #  endif
 #endif
 
+#ifdef Q_COMPILER_RVALUE_REFS
+#define qMove(x) std::move(x)
+#else
+#define qMove(x) (x)
+#endif
+
 #endif // QCOMPILERDETECTION_H
index 1bc02e0..9008591 100644 (file)
@@ -3006,4 +3006,12 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
         {Debugging Techniques}
 */
 
+/*!
+    \macro qMove(x)
+    \relates <QtGlobal>
+
+    It expands to "std::move" if your compiler supports that C++11 function, or to nothing
+    otherwise.
+*/
+
 QT_END_NAMESPACE
index 26e3ccf..f9905ce 100644 (file)
@@ -2556,6 +2556,9 @@ void testContainer()
         c1 = newInstance<Container>();
         QVERIFY(c1.size() == 4);
         QVERIFY(c1 == newInstance<Container>());
+        Container c2 = qMove(c1);
+        QVERIFY(c2.size() == 4);
+        QVERIFY(c2 == newInstance<Container>());
     }
 }