Add qMove macro to support std::move

Change-Id: I373e07f479c11b172dab35ed7e5b62724aa50a1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Olivier Goffart 2012-04-25 11:09:48 +02:00 committed by Qt by Nokia
parent e4505acd12
commit 958aaf3770
3 changed files with 17 additions and 0 deletions

View File

@ -779,4 +779,10 @@
# endif
#endif
#ifdef Q_COMPILER_RVALUE_REFS
#define qMove(x) std::move(x)
#else
#define qMove(x) (x)
#endif
#endif // QCOMPILERDETECTION_H

View 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

View 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>());
}
}