summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qtypeinfo.h129
-rw-r--r--src/corelib/kernel/qmetatype.h2
-rw-r--r--src/corelib/tools/qarraydataops.h8
-rw-r--r--src/corelib/tools/qcontainertools_impl.h4
-rw-r--r--src/corelib/tools/qvarlengtharray.h4
-rw-r--r--src/gui/math3d/qgenericmatrix.h8
6 files changed, 21 insertions, 134 deletions
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index e45347ee10..30db5c4487 100644
--- a/src/corelib/global/qtypeinfo.h
+++ b/src/corelib/global/qtypeinfo.h
@@ -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,53 +81,11 @@ 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
\internal
@@ -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
{
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index bf76f39a2a..cfc5f06c90 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -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)
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index f787dacfac..f6384ca998 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -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;
diff --git a/src/corelib/tools/qcontainertools_impl.h b/src/corelib/tools/qcontainertools_impl.h
index 44cfdc444e..a7e1aa31cd 100644
--- a/src/corelib/tools/qcontainertools_impl.h
+++ b/src/corelib/tools/qcontainertools_impl.h
@@ -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);
}
}
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index a70fc75fcf..01571e3e9f 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -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;
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index 81fc9eee62..1381014a04 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -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)