Cleanup QTypeInfo
Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6. Also remove sizeOf, it's unused, and we have QMetaType for that if required. Remove all typeinfo declaractions for trivial types, as the default template covers them correctly nowadays. Finally set up a better default for isPointer, and do some smaller cleanups all over the place. Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
db21bad936
commit
acbf9a858b
@ -55,16 +55,7 @@ class QDebug;
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool qIsRelocatable()
|
||||
{
|
||||
return std::is_trivially_copyable<T>::value && std::is_trivially_destructible<T>::value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool qIsTrivial()
|
||||
{
|
||||
return std::is_trivial<T>::value;
|
||||
}
|
||||
static constexpr bool qIsRelocatable = std::is_trivially_copyable_v<T> && std::is_trivially_destructible_v<T>;
|
||||
|
||||
/*
|
||||
The catch-all template.
|
||||
@ -75,12 +66,10 @@ class QTypeInfo
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
isPointer = false,
|
||||
isIntegral = std::is_integral<T>::value,
|
||||
isComplex = !qIsTrivial<T>(),
|
||||
isStatic = true,
|
||||
isRelocatable = qIsRelocatable<T>(),
|
||||
sizeOf = sizeof(T)
|
||||
isPointer = std::is_pointer_v<T>,
|
||||
isIntegral = std::is_integral_v<T>,
|
||||
isComplex = !std::is_trivial_v<T>,
|
||||
isRelocatable = qIsRelocatable<T>,
|
||||
};
|
||||
};
|
||||
|
||||
@ -92,52 +81,10 @@ public:
|
||||
isPointer = false,
|
||||
isIntegral = false,
|
||||
isComplex = false,
|
||||
isStatic = false,
|
||||
isRelocatable = false,
|
||||
sizeOf = 0
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class QTypeInfo<T*>
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
isPointer = true,
|
||||
isIntegral = false,
|
||||
isComplex = false,
|
||||
isStatic = false,
|
||||
isRelocatable = true,
|
||||
sizeOf = sizeof(T*)
|
||||
};
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QTypeInfoQuery
|
||||
\inmodule QtCore
|
||||
\internal
|
||||
\brief QTypeInfoQuery is used to query the values of a given QTypeInfo<T>
|
||||
|
||||
We use it because there may be some QTypeInfo<T> specializations in user
|
||||
code that don't provide certain flags that we added after Qt 5.0. They are:
|
||||
\list
|
||||
\li isRelocatable: defaults to !isStatic
|
||||
\endlist
|
||||
|
||||
DO NOT specialize this class elsewhere.
|
||||
*/
|
||||
// apply defaults for a generic QTypeInfo<T> that didn't provide the new values
|
||||
template <typename T, typename = void>
|
||||
struct QTypeInfoQuery : public QTypeInfo<T>
|
||||
{
|
||||
enum { isRelocatable = !QTypeInfo<T>::isStatic };
|
||||
};
|
||||
|
||||
// if QTypeInfo<T>::isRelocatable exists, use it
|
||||
template <typename T>
|
||||
struct QTypeInfoQuery<T, typename std::enable_if<QTypeInfo<T>::isRelocatable || true>::type> : public QTypeInfo<T>
|
||||
{};
|
||||
|
||||
/*!
|
||||
\class QTypeInfoMerger
|
||||
\inmodule QtCore
|
||||
@ -163,12 +110,10 @@ class QTypeInfoMerger
|
||||
{
|
||||
static_assert(sizeof...(Ts) > 0);
|
||||
public:
|
||||
static constexpr bool isComplex = ((QTypeInfoQuery<Ts>::isComplex) || ...);
|
||||
static constexpr bool isStatic = ((QTypeInfoQuery<Ts>::isStatic) || ...);
|
||||
static constexpr bool isRelocatable = ((QTypeInfoQuery<Ts>::isRelocatable) && ...);
|
||||
static constexpr bool isComplex = ((QTypeInfo<Ts>::isComplex) || ...);
|
||||
static constexpr bool isRelocatable = ((QTypeInfo<Ts>::isRelocatable) && ...);
|
||||
static constexpr bool isPointer = false;
|
||||
static constexpr bool isIntegral = false;
|
||||
static constexpr std::size_t sizeOf = sizeof(T);
|
||||
};
|
||||
|
||||
#define Q_DECLARE_MOVABLE_CONTAINER(CONTAINER) \
|
||||
@ -182,8 +127,6 @@ public: \
|
||||
isIntegral = false, \
|
||||
isComplex = true, \
|
||||
isRelocatable = true, \
|
||||
isStatic = false, \
|
||||
sizeOf = sizeof(CONTAINER<T>) \
|
||||
}; \
|
||||
}
|
||||
|
||||
@ -204,9 +147,7 @@ public: \
|
||||
isPointer = false, \
|
||||
isIntegral = false, \
|
||||
isComplex = true, \
|
||||
isStatic = false, \
|
||||
isRelocatable = true, \
|
||||
sizeOf = sizeof(CONTAINER<K, V>) \
|
||||
}; \
|
||||
}
|
||||
|
||||
@ -228,10 +169,9 @@ Q_DECLARE_MOVABLE_CONTAINER(QMultiHash);
|
||||
enum { /* TYPEINFO flags */
|
||||
Q_COMPLEX_TYPE = 0,
|
||||
Q_PRIMITIVE_TYPE = 0x1,
|
||||
Q_STATIC_TYPE = 0,
|
||||
Q_MOVABLE_TYPE = 0x2, // ### Qt6: merge movable and relocatable once QList no longer depends on it
|
||||
Q_RELOCATABLE_TYPE = 0x2,
|
||||
Q_MOVABLE_TYPE = 0x2,
|
||||
Q_DUMMY_TYPE = 0x4,
|
||||
Q_RELOCATABLE_TYPE = 0x8
|
||||
};
|
||||
|
||||
#define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) \
|
||||
@ -239,14 +179,11 @@ class QTypeInfo<TYPE > \
|
||||
{ \
|
||||
public: \
|
||||
enum { \
|
||||
isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0) && !qIsTrivial<TYPE>(), \
|
||||
isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
|
||||
isRelocatable = !isStatic || ((FLAGS) & Q_RELOCATABLE_TYPE) || qIsRelocatable<TYPE>(), \
|
||||
isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0) && !std::is_trivial_v<TYPE>, \
|
||||
isRelocatable = !isComplex || ((FLAGS) & Q_RELOCATABLE_TYPE) || qIsRelocatable<TYPE>, \
|
||||
isPointer = false, \
|
||||
isIntegral = std::is_integral< TYPE >::value, \
|
||||
sizeOf = sizeof(TYPE) \
|
||||
}; \
|
||||
static inline const char *name() { return #TYPE; } \
|
||||
}
|
||||
|
||||
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
|
||||
@ -283,50 +220,6 @@ inline void swap(TYPE &value1, TYPE &value2) \
|
||||
#define Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(TYPE) \
|
||||
Q_DECLARE_SHARED_IMPL(TYPE, QT_VERSION >= QT_VERSION_CHECK(6,0,0) ? Q_MOVABLE_TYPE : Q_RELOCATABLE_TYPE)
|
||||
|
||||
/*
|
||||
QTypeInfo primitive specializations
|
||||
*/
|
||||
Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
|
||||
// ### Qt 6: remove the other branch
|
||||
// This was required so that QList<T> for these types allocates out of the array storage
|
||||
Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
|
||||
# ifdef Q_COMPILER_UNICODE_STRINGS
|
||||
Q_DECLARE_TYPEINFO(char16_t, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(char32_t, Q_PRIMITIVE_TYPE);
|
||||
# endif
|
||||
# if !defined(Q_CC_MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
Q_DECLARE_TYPEINFO(wchar_t, Q_PRIMITIVE_TYPE);
|
||||
# endif
|
||||
#else
|
||||
# ifndef Q_OS_DARWIN
|
||||
Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
|
||||
# else
|
||||
Q_DECLARE_TYPEINFO(long double, Q_RELOCATABLE_TYPE);
|
||||
# endif
|
||||
# ifdef Q_COMPILER_UNICODE_STRINGS
|
||||
Q_DECLARE_TYPEINFO(char16_t, Q_RELOCATABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(char32_t, Q_RELOCATABLE_TYPE);
|
||||
# endif
|
||||
# if !defined(Q_CC_MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
Q_DECLARE_TYPEINFO(wchar_t, Q_RELOCATABLE_TYPE);
|
||||
# endif
|
||||
#endif // Qt 6
|
||||
|
||||
namespace QTypeTraits
|
||||
{
|
||||
|
||||
|
@ -1459,7 +1459,7 @@ namespace QtPrivate {
|
||||
template<typename T>
|
||||
struct QMetaTypeTypeFlags
|
||||
{
|
||||
enum { Flags = (QTypeInfoQuery<T>::isRelocatable ? QMetaType::MovableType : 0)
|
||||
enum { Flags = (QTypeInfo<T>::isRelocatable ? QMetaType::MovableType : 0)
|
||||
| (QTypeInfo<T>::isComplex ? QMetaType::NeedsConstruction : 0)
|
||||
| (QTypeInfo<T>::isComplex ? QMetaType::NeedsDestruction : 0)
|
||||
| (IsPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::PointerToQObject : 0)
|
||||
|
@ -174,7 +174,7 @@ struct QArrayExceptionSafetyPrimitives
|
||||
T *const end;
|
||||
qsizetype displace;
|
||||
|
||||
static_assert(QTypeInfoQuery<T>::isRelocatable, "Type must be relocatable");
|
||||
static_assert(QTypeInfo<T>::isRelocatable, "Type must be relocatable");
|
||||
|
||||
Displacer(T *start, T *finish, qsizetype diff) noexcept
|
||||
: begin(start), end(finish), displace(diff)
|
||||
@ -201,7 +201,7 @@ struct QArrayExceptionSafetyPrimitives
|
||||
size_t n;
|
||||
qsizetype &size;
|
||||
|
||||
static_assert(QTypeInfoQuery<T>::isRelocatable, "Type must be relocatable");
|
||||
static_assert(QTypeInfo<T>::isRelocatable, "Type must be relocatable");
|
||||
|
||||
Mover(T *&start, size_t length, qsizetype &sz) noexcept
|
||||
: destination(start), source(start), n(length), size(sz)
|
||||
@ -1018,7 +1018,7 @@ struct QArrayOpsSelector
|
||||
template <class T>
|
||||
struct QArrayOpsSelector<T,
|
||||
typename std::enable_if<
|
||||
!QTypeInfoQuery<T>::isComplex && QTypeInfoQuery<T>::isRelocatable
|
||||
!QTypeInfo<T>::isComplex && QTypeInfo<T>::isRelocatable
|
||||
>::type>
|
||||
{
|
||||
typedef QPodArrayOps<T> Type;
|
||||
@ -1027,7 +1027,7 @@ struct QArrayOpsSelector<T,
|
||||
template <class T>
|
||||
struct QArrayOpsSelector<T,
|
||||
typename std::enable_if<
|
||||
QTypeInfoQuery<T>::isComplex && QTypeInfoQuery<T>::isRelocatable
|
||||
QTypeInfo<T>::isComplex && QTypeInfo<T>::isRelocatable
|
||||
>::type>
|
||||
{
|
||||
typedef QMovableArrayOps<T> Type;
|
||||
|
@ -61,7 +61,7 @@ namespace QtPrivate
|
||||
template <typename T, typename N>
|
||||
void q_uninitialized_relocate_n(T* first, N n, T* out)
|
||||
{
|
||||
if constexpr (QTypeInfoQuery<T>::isRelocatable) {
|
||||
if constexpr (QTypeInfo<T>::isRelocatable) {
|
||||
if (n != N(0)) { // even if N == 0, out == nullptr or first == nullptr are UB for memmove()
|
||||
std::memmove(static_cast<void*>(out),
|
||||
static_cast<const void*>(first),
|
||||
@ -69,7 +69,7 @@ void q_uninitialized_relocate_n(T* first, N n, T* out)
|
||||
}
|
||||
} else {
|
||||
std::uninitialized_move_n(first, n, out);
|
||||
if constexpr (QTypeInfoQuery<T>::isComplex)
|
||||
if constexpr (QTypeInfo<T>::isComplex)
|
||||
std::destroy_n(first, n);
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(qsizetype asize,
|
||||
a = Prealloc;
|
||||
}
|
||||
s = 0;
|
||||
if (!QTypeInfoQuery<T>::isRelocatable) {
|
||||
if (!QTypeInfo<T>::isRelocatable) {
|
||||
QT_TRY {
|
||||
// move all the old elements
|
||||
while (s < copySize) {
|
||||
@ -556,7 +556,7 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthA
|
||||
if (n != 0) {
|
||||
resize(s + n);
|
||||
const T copy(t);
|
||||
if (!QTypeInfoQuery<T>::isRelocatable) {
|
||||
if (!QTypeInfo<T>::isRelocatable) {
|
||||
T *b = ptr + offset;
|
||||
T *j = ptr + s;
|
||||
T *i = j - n;
|
||||
|
@ -108,12 +108,6 @@ template <int N, int M, typename T>
|
||||
class QTypeInfo<QGenericMatrix<N, M, T> >
|
||||
: public QTypeInfoMerger<QGenericMatrix<N, M, T>, T>
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
public:
|
||||
enum {
|
||||
isStatic = true,
|
||||
}; // at least Q_RELOCATABLE_TYPE, for BC during Qt 5
|
||||
#endif
|
||||
};
|
||||
|
||||
template <int N, int M, typename T>
|
||||
@ -350,7 +344,7 @@ QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T> &m)
|
||||
{
|
||||
QDebugStateSaver saver(dbg);
|
||||
dbg.nospace() << "QGenericMatrix<" << N << ", " << M
|
||||
<< ", " << QTypeInfo<T>::name()
|
||||
<< ", " << QMetaType::fromType<T>().name()
|
||||
<< ">(" << Qt::endl << qSetFieldWidth(10);
|
||||
for (int row = 0; row < M; ++row) {
|
||||
for (int col = 0; col < N; ++col)
|
||||
|
@ -152,7 +152,7 @@ enum class MyStrictNoOpEnum { StrictZero, StrictOne, StrictTwo, StrictFour=4 };
|
||||
Q_DECLARE_FLAGS( MyStrictNoOpFlags, MyStrictNoOpEnum )
|
||||
|
||||
static_assert( !QTypeInfo<MyStrictFlags>::isComplex );
|
||||
static_assert( !QTypeInfo<MyStrictFlags>::isStatic );
|
||||
static_assert( QTypeInfo<MyStrictFlags>::isRelocatable );
|
||||
static_assert( !QTypeInfo<MyStrictFlags>::isPointer );
|
||||
|
||||
void tst_QFlags::classEnum()
|
||||
@ -322,7 +322,7 @@ Q_DECLARE_FLAGS( MyFlags, MyEnum )
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags )
|
||||
|
||||
static_assert( !QTypeInfo<MyFlags>::isComplex );
|
||||
static_assert( !QTypeInfo<MyFlags>::isStatic );
|
||||
static_assert( QTypeInfo<MyFlags>::isRelocatable );
|
||||
static_assert( !QTypeInfo<MyFlags>::isPointer );
|
||||
|
||||
QTEST_MAIN(tst_QFlags)
|
||||
|
@ -919,6 +919,11 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_COPY_FUNCTION)
|
||||
TypeTestFunctionGetter::get(type)();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr size_t getSize = sizeof(T);
|
||||
template<>
|
||||
constexpr size_t getSize<void> = 0;
|
||||
|
||||
void tst_QMetaType::sizeOf_data()
|
||||
{
|
||||
QTest::addColumn<int>("type");
|
||||
@ -926,7 +931,7 @@ void tst_QMetaType::sizeOf_data()
|
||||
|
||||
QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << size_t(0);
|
||||
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
|
||||
QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << size_t(QTypeInfo<RealType>::sizeOf);
|
||||
QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << getSize<RealType>;
|
||||
FOR_EACH_CORE_METATYPE(ADD_METATYPE_TEST_ROW)
|
||||
#undef ADD_METATYPE_TEST_ROW
|
||||
|
||||
@ -1074,8 +1079,8 @@ void tst_QMetaType::flags_data()
|
||||
|
||||
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
|
||||
QTest::newRow(#RealType) << MetaTypeId \
|
||||
<< bool(QTypeInfoQuery<RealType>::isRelocatable) \
|
||||
<< bool(QTypeInfoQuery<RealType>::isComplex) \
|
||||
<< bool(QTypeInfo<RealType>::isRelocatable) \
|
||||
<< bool(QTypeInfo<RealType>::isComplex) \
|
||||
<< bool(QtPrivate::IsPointerToTypeDerivedFromQObject<RealType>::Value) \
|
||||
<< bool(std::is_enum<RealType>::value);
|
||||
QT_FOR_EACH_STATIC_CORE_CLASS(ADD_METATYPE_TEST_ROW)
|
||||
|
@ -3187,7 +3187,7 @@ template<class T> void playWithVariant(const T &orig, bool isNull, const QString
|
||||
|
||||
{
|
||||
QVariant v2 = v;
|
||||
if (!(QTypeInfo<T>::isStatic && QTypeInfo<T>::isComplex)) {
|
||||
if (QTypeInfo<T>::isRelocatable) {
|
||||
// Type is movable so standard comparison algorithm in QVariant should work
|
||||
// In a custom type QVariant is not aware of ==operator so it won't be called,
|
||||
// which may cause problems especially visible when using a not-movable type
|
||||
@ -3204,7 +3204,7 @@ template<class T> void playWithVariant(const T &orig, bool isNull, const QString
|
||||
v = QVariant();
|
||||
QCOMPARE(v3, v);
|
||||
v = v2;
|
||||
if (!(QTypeInfo<T>::isStatic && QTypeInfo<T>::isComplex)) {
|
||||
if (QTypeInfo<T>::isRelocatable) {
|
||||
// Type is movable so standard comparison algorithm in QVariant should work
|
||||
// In a custom type QVariant is not aware of ==operator so it won't be called,
|
||||
// which may cause problems especially visible when using a not-movable type
|
||||
|
@ -1880,7 +1880,7 @@ void tst_QByteArray::movablity()
|
||||
{
|
||||
QFETCH(QByteArray, array);
|
||||
|
||||
static_assert(!QTypeInfo<QByteArray>::isStatic);
|
||||
static_assert(QTypeInfo<QByteArray>::isRelocatable);
|
||||
|
||||
const int size = array.size();
|
||||
const bool isEmpty = array.isEmpty();
|
||||
|
@ -800,9 +800,12 @@ void tst_QArrayData::arrayOps()
|
||||
};
|
||||
const CountedObject objArray[5];
|
||||
|
||||
QVERIFY(!QTypeInfo<int>::isComplex && !QTypeInfo<int>::isStatic);
|
||||
QVERIFY(QTypeInfo<QString>::isComplex && !QTypeInfo<QString>::isStatic);
|
||||
QVERIFY(QTypeInfo<CountedObject>::isComplex && QTypeInfo<CountedObject>::isStatic);
|
||||
static_assert(!QTypeInfo<int>::isComplex);
|
||||
static_assert(QTypeInfo<int>::isRelocatable);
|
||||
static_assert(QTypeInfo<QString>::isComplex);
|
||||
static_assert(QTypeInfo<QString>::isRelocatable);
|
||||
static_assert(QTypeInfo<CountedObject>::isComplex);
|
||||
static_assert(!QTypeInfo<CountedObject>::isRelocatable);
|
||||
|
||||
QCOMPARE(CountedObject::liveCount, size_t(5));
|
||||
for (size_t i = 0; i < 5; ++i)
|
||||
|
@ -184,11 +184,11 @@ inline size_t qHash(const Custom &key, size_t seed = 0) { return qHash(key.i, se
|
||||
Q_DECLARE_METATYPE(Custom);
|
||||
|
||||
// tests depends on the fact that:
|
||||
static_assert(!QTypeInfo<int>::isStatic);
|
||||
static_assert(QTypeInfo<int>::isRelocatable);
|
||||
static_assert(!QTypeInfo<int>::isComplex);
|
||||
static_assert(!QTypeInfo<Movable>::isStatic);
|
||||
static_assert(QTypeInfo<Movable>::isRelocatable);
|
||||
static_assert(QTypeInfo<Movable>::isComplex);
|
||||
static_assert(QTypeInfo<Custom>::isStatic);
|
||||
static_assert(!QTypeInfo<Custom>::isRelocatable);
|
||||
static_assert(QTypeInfo<Custom>::isComplex);
|
||||
|
||||
|
||||
@ -2144,7 +2144,7 @@ void tst_QList::resizePOD_data() const
|
||||
QTest::addColumn<int>("size");
|
||||
|
||||
QVERIFY(!QTypeInfo<int>::isComplex);
|
||||
QVERIFY(!QTypeInfo<int>::isStatic);
|
||||
QVERIFY(QTypeInfo<int>::isRelocatable);
|
||||
|
||||
QList<int> null;
|
||||
QList<int> empty(0, 5);
|
||||
@ -2192,7 +2192,7 @@ void tst_QList::resizeComplexMovable_data() const
|
||||
QTest::addColumn<int>("size");
|
||||
|
||||
QVERIFY(QTypeInfo<Movable>::isComplex);
|
||||
QVERIFY(!QTypeInfo<Movable>::isStatic);
|
||||
QVERIFY(QTypeInfo<Movable>::isRelocatable);
|
||||
|
||||
QList<Movable> null;
|
||||
QList<Movable> empty(0, 'Q');
|
||||
@ -2244,7 +2244,7 @@ void tst_QList::resizeComplex_data() const
|
||||
QTest::addColumn<int>("size");
|
||||
|
||||
QVERIFY(QTypeInfo<Custom>::isComplex);
|
||||
QVERIFY(QTypeInfo<Custom>::isStatic);
|
||||
QVERIFY(!QTypeInfo<Custom>::isRelocatable);
|
||||
|
||||
QList<Custom> null;
|
||||
QList<Custom> empty(0, '0');
|
||||
|
@ -43,7 +43,7 @@ private Q_SLOTS:
|
||||
void testDeductionRules();
|
||||
};
|
||||
|
||||
class C { C() {} Q_DECL_UNUSED_MEMBER char _[4]; };
|
||||
class C { C() {} ~C() {} Q_DECL_UNUSED_MEMBER char _[4]; };
|
||||
class M { M() {} Q_DECL_UNUSED_MEMBER char _[4]; };
|
||||
class P { Q_DECL_UNUSED_MEMBER char _[4]; };
|
||||
|
||||
@ -64,31 +64,31 @@ typedef QPair<P,M> QPairPM;
|
||||
typedef QPair<P,P> QPairPP;
|
||||
|
||||
static_assert( QTypeInfo<QPairCC>::isComplex);
|
||||
static_assert( QTypeInfo<QPairCC>::isStatic );
|
||||
static_assert( !QTypeInfo<QPairCC>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairCM>::isComplex);
|
||||
static_assert( QTypeInfo<QPairCM>::isStatic );
|
||||
static_assert( !QTypeInfo<QPairCM>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairCP>::isComplex);
|
||||
static_assert( QTypeInfo<QPairCP>::isStatic );
|
||||
static_assert( !QTypeInfo<QPairCP>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairMC>::isComplex);
|
||||
static_assert( QTypeInfo<QPairMC>::isStatic );
|
||||
static_assert( !QTypeInfo<QPairMC>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairMM>::isComplex);
|
||||
static_assert(!QTypeInfo<QPairMM>::isStatic );
|
||||
static_assert( QTypeInfo<QPairMM>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairMP>::isComplex);
|
||||
static_assert(!QTypeInfo<QPairMP>::isStatic );
|
||||
static_assert( QTypeInfo<QPairMP>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairPC>::isComplex);
|
||||
static_assert( QTypeInfo<QPairPC>::isStatic );
|
||||
static_assert( !QTypeInfo<QPairPC>::isRelocatable );
|
||||
|
||||
static_assert( QTypeInfo<QPairPM>::isComplex);
|
||||
static_assert(!QTypeInfo<QPairPM>::isStatic );
|
||||
static_assert( QTypeInfo<QPairPM>::isRelocatable );
|
||||
|
||||
static_assert(!QTypeInfo<QPairPP>::isComplex);
|
||||
static_assert(!QTypeInfo<QPairPP>::isStatic );
|
||||
static_assert( QTypeInfo<QPairPP>::isRelocatable );
|
||||
|
||||
static_assert(!QTypeInfo<QPairPP>::isPointer);
|
||||
|
||||
|
@ -528,11 +528,11 @@ void reallocTest()
|
||||
|
||||
typedef QVarLengthArray<T, 16> Container;
|
||||
enum {
|
||||
isStatic = QTypeInfo<T>::isStatic,
|
||||
isRelocatable = QTypeInfo<T>::isRelocatable,
|
||||
isComplex = QTypeInfo<T>::isComplex,
|
||||
|
||||
isPrimitive = !isComplex && !isStatic,
|
||||
isMovable = !isStatic
|
||||
isPrimitive = !isComplex && isRelocatable,
|
||||
isMovable = isRelocatable
|
||||
};
|
||||
|
||||
// Constructors
|
||||
|
@ -325,7 +325,7 @@ void tst_QGuiMetaType::flags_data()
|
||||
QTest::addColumn<bool>("isComplex");
|
||||
|
||||
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
|
||||
QTest::newRow(#RealType) << MetaTypeId << bool(QTypeInfoQuery<RealType>::isRelocatable) << bool(QTypeInfoQuery<RealType>::isComplex);
|
||||
QTest::newRow(#RealType) << MetaTypeId << bool(QTypeInfo<RealType>::isRelocatable) << bool(QTypeInfo<RealType>::isComplex);
|
||||
QT_FOR_EACH_STATIC_GUI_CLASS(ADD_METATYPE_TEST_ROW)
|
||||
#undef ADD_METATYPE_TEST_ROW
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ void QRawVector<T>::realloc(int asize, int aalloc, bool ref)
|
||||
T *xbegin = m_begin;
|
||||
if (aalloc != xalloc || ref) {
|
||||
// (re)allocate memory
|
||||
if (QTypeInfo<T>::isStatic) {
|
||||
if (!QTypeInfo<T>::isRelocatable) {
|
||||
xbegin = allocate(aalloc);
|
||||
xsize = 0;
|
||||
changed = true;
|
||||
@ -462,7 +462,7 @@ typename QRawVector<T>::iterator QRawVector<T>::insert(iterator before, size_typ
|
||||
const T copy(t);
|
||||
if (m_size + n > m_alloc)
|
||||
realloc(m_size, QVectorData::grow(offsetOfTypedData(), m_size + n, sizeof(T)), false);
|
||||
if (QTypeInfo<T>::isStatic) {
|
||||
if (!QTypeInfo<T>::isRelocatable) {
|
||||
T *b = m_begin + m_size;
|
||||
T *i = m_begin + m_size + n;
|
||||
while (i != b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user