[Development] QMetaType and non-const references
volker.hilsheimer at qt.io
Tue Jul 19 20:45:29 CEST 2022
> On 19 Jul 2022, at 18:08, Thiago Macieira <thiago.macieira at intel.com> wrote:
>> Lastly, an aside: Q_DECLARE_METATYPE being effectively unnecessary was the
>> goal for Qt 6, but is not the case yet. I consider that a bug that should
>> finally be fixed in 6.5.
> Right. There should be exactly one use for Q_DECLARE_METATYPE: when the name
> you want to register is not the name that the C++ language recognises for your
> type, and this should only be done for legacy reasons.
> typedef QMap<int, int> IntMap;
> And you may have the string "IntMap" somewhere in your meta objects.
qDe0bug() << QMetaType::fromType<std::string>().name();
qDebug() << QMetaType::fromName("std::string");
prints, with Apple clang:
but with msvc 22:
and then "std::string" in your meta object won’t work either, I suppose?
But interestingly, neither does
with clang and
with msvc 22. What does that mean if e.g. "std::string" is present in a meta object?
> Any opinion on what must happen together or not at all?
I agree with Fabian, it seems uncontroversial to treat T& and T as different types in the QMetaType system. Code that relies on them being the same needs to be fixed anyway. Doing that doesn’t seem to prevent anything else discussed.
More information about the Development