summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetacontainer.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-09 15:33:05 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-18 13:48:16 +0200
commit9ceedd586321a2eeac4b63ee90d4e9726e143b78 (patch)
tree0647908ccaf4f4eca43140880eef4d4efe30f43d /src/corelib/kernel/qmetacontainer.h
parent0b0acce5a7b2b209e6359e64d91d300a4eb70a3c (diff)
Make most of QMetaTypeInterface constexpr
The only thing we need to modify at runtime is the typeId and that can be mutable. This way we can have a constexpr ctor for QMetaType which hopefully makes the importing and exporting of related symbols less fickle. On Windows we cannot make QMetaTypeForType constexpr as that leads to mysterious errors in other places. Until we figure out why that is, we just leave this class as non-constexpr. This reveals that qcoreapplication.h and qvariant.h are using QDebug without including it. We now get template instantiation errors. Include qdebug.h to avoid that. Change-Id: If1bf0437ada52459c59c6fa45bab3d22dfb0bc92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetacontainer.h')
-rw-r--r--src/corelib/kernel/qmetacontainer.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/kernel/qmetacontainer.h b/src/corelib/kernel/qmetacontainer.h
index a873bb2106..4bce731d8a 100644
--- a/src/corelib/kernel/qmetacontainer.h
+++ b/src/corelib/kernel/qmetacontainer.h
@@ -50,7 +50,7 @@ class QMetaType;
namespace QtPrivate {
class QMetaTypeInterface;
template<typename T>
-constexpr QMetaTypeInterface *qMetaTypeInterfaceForType();
+constexpr const QMetaTypeInterface *qMetaTypeInterfaceForType();
}
namespace QtMetaContainerPrivate {
@@ -132,7 +132,7 @@ public:
class QMetaSequenceInterface : public QMetaContainerInterface
{
public:
- QtPrivate::QMetaTypeInterface *valueMetaType;
+ const QtPrivate::QMetaTypeInterface *valueMetaType;
AddRemoveCapabilities addRemoveCapabilities;
using ValueAtIndexFn = void(*)(const void *, qsizetype, void *);
@@ -183,8 +183,8 @@ public:
class QMetaAssociationInterface : public QMetaContainerInterface
{
public:
- QtPrivate::QMetaTypeInterface *keyMetaType;
- QtPrivate::QMetaTypeInterface *mappedMetaType;
+ const QtPrivate::QMetaTypeInterface *keyMetaType;
+ const QtPrivate::QMetaTypeInterface *mappedMetaType;
using InsertKeyFn = void(*)(void *, const void *);
InsertKeyFn insertKeyFn;
@@ -470,7 +470,7 @@ class QMetaSequenceForContainer : public QMetaContainerForContainer<C>
{
friend QMetaSequenceInterface;
- static constexpr QtPrivate::QMetaTypeInterface *getValueMetaType()
+ static constexpr const QtPrivate::QMetaTypeInterface *getValueMetaType()
{
if constexpr (QContainerTraits::has_value_type_v<C>)
return QtPrivate::qMetaTypeInterfaceForType<typename C::value_type>();
@@ -697,7 +697,7 @@ class QMetaAssociationForContainer : public QMetaContainerForContainer<C>
{
friend QMetaAssociationInterface;
- static constexpr QtPrivate::QMetaTypeInterface *getKeyMetaType()
+ static constexpr const QtPrivate::QMetaTypeInterface *getKeyMetaType()
{
if constexpr (QContainerTraits::has_key_type_v<C>)
return QtPrivate::qMetaTypeInterfaceForType<typename C::key_type>();
@@ -705,7 +705,7 @@ class QMetaAssociationForContainer : public QMetaContainerForContainer<C>
return nullptr;
}
- static constexpr QtPrivate::QMetaTypeInterface *getMappedMetaType()
+ static constexpr const QtPrivate::QMetaTypeInterface *getMappedMetaType()
{
if constexpr (QContainerTraits::has_mapped_type_v<C>)
return QtPrivate::qMetaTypeInterfaceForType<typename C::mapped_type>();