Mark the single argument containers as movable.
Change-Id: I1557b9f3c2d3ad805e1ab7bf4d49973f08664a79 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
This commit is contained in:
parent
6b4f8a68c8
commit
61e8487e8e
@ -2050,6 +2050,31 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
|
||||
template <typename T> class CONTAINER; \
|
||||
template <typename T> \
|
||||
class QTypeInfo< CONTAINER<T> > \
|
||||
{ \
|
||||
public: \
|
||||
enum { \
|
||||
isPointer = false, \
|
||||
isComplex = true, \
|
||||
isStatic = false, \
|
||||
isLarge = (sizeof(CONTAINER<T>) > sizeof(void*)), \
|
||||
isDummy = false \
|
||||
}; \
|
||||
};
|
||||
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QList)
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QVector)
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QQueue)
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QStack)
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QLinkedList)
|
||||
Q_DECLARE_MOVABLE_CONTAINER(QSet)
|
||||
|
||||
#undef Q_DECLARE_MOVABLE_CONTAINER
|
||||
|
||||
/*
|
||||
Specialize a specific type with:
|
||||
|
||||
|
@ -3254,6 +3254,34 @@ void tst_QVariant::moreCustomTypes()
|
||||
PLAY_WITH_VARIANT(d, false, QString(), 0, false);
|
||||
}
|
||||
QCOMPARE(MyMovable::count, 0);
|
||||
|
||||
{
|
||||
QList<QList<int> > data;
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
data << (QList<int>() << 42);
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
}
|
||||
|
||||
{
|
||||
QList<QVector<int> > data;
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
data << (QVector<int>() << 42);
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
}
|
||||
|
||||
{
|
||||
QList<QSet<int> > data;
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
data << (QSet<int>() << 42);
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
}
|
||||
|
||||
{
|
||||
QList<QLinkedList<int> > data;
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
data << (QLinkedList<int>() << 42);
|
||||
PLAY_WITH_VARIANT(data, false, QString(), 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVariant::movabilityTest()
|
||||
|
Loading…
Reference in New Issue
Block a user