summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qarraydata
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-03-08 11:48:26 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-08 12:10:29 +0100
commit8141e34280a92088a527e0935765ad8ba8e92be8 (patch)
tree583fa45bdf36795f34cb64d8593f32fcd58b5454 /tests/auto/corelib/tools/qarraydata
parent79f2480c868523a7d8ffc9fb15055e8eab3237ba (diff)
Skip test when implicit move operators not available
Besides rvalue-references, this test depends on the compiler to generate implicit move operators on a derived class, based on the ones available on its base class. At least Visual Studio 2010 and some variations of clang 3.0 are known not to generate implicit move constructors and assignment operators. Gcc 4.6 and up seem to support the feature. Change-Id: Ied464ef678f517321b19f8a7bacddb6cd6665585 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qarraydata')
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index f3f1daba0f..884f4f7d1d 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -1356,11 +1356,54 @@ typename RemoveReference<T>::Type &&cxx11Move(T &&t)
{
return static_cast<typename RemoveReference<T>::Type &&>(t);
}
+
+struct CompilerHasCxx11ImplicitMoves
+{
+ static bool value()
+ {
+ DetectImplicitMove d(cxx11Move(DetectImplicitMove()));
+ return d.constructor == DetectConstructor::MoveConstructor;
+ }
+
+ struct DetectConstructor
+ {
+ Q_DECL_CONSTEXPR DetectConstructor()
+ : constructor(DefaultConstructor)
+ {
+ }
+
+ Q_DECL_CONSTEXPR DetectConstructor(const DetectConstructor &)
+ : constructor(CopyConstructor)
+ {
+ }
+
+ Q_DECL_CONSTEXPR DetectConstructor(DetectConstructor &&)
+ : constructor(MoveConstructor)
+ {
+ }
+
+ enum Constructor {
+ DefaultConstructor,
+ CopyConstructor,
+ MoveConstructor
+ };
+
+ Constructor constructor;
+ };
+
+ struct DetectImplicitMove
+ : DetectConstructor
+ {
+ };
+};
#endif
void tst_QArrayData::rValueReferences()
{
#ifdef Q_COMPILER_RVALUE_REFS
+ if (!CompilerHasCxx11ImplicitMoves::value())
+ QSKIP("Implicit move ctor not supported in current configuration");
+
SimpleVector<int> v1(1, 42);
SimpleVector<int> v2;