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>
This commit is contained in:
parent
79f2480c86
commit
8141e34280
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user