[Development] Should qMetaTypeId<const T>() == qMetaTypeId<T>()?
Olivier Goffart
olivier at woboq.com
Sat Aug 27 09:30:21 CEST 2016
On Mittwoch, 24. August 2016 16:06:50 CEST Jędrzej Nowacki wrote:
> On onsdag 24. august 2016 15.23.01 CEST Marc Mutz wrote:
> > Hi,
> >
> > Currently, it's not, which doesn't make much sense, does it?
> >
> > So,
> >
> > template <typename T>
> > int qMetyTypeId<T>() {
> > return qMetaTypeIdHelper<typename std::remove_cv<T>::type>();
> > }
> > ?
> >
> > (There's of course a lot more involved in this, registration should
> > discard const, too, e.g.).
I think it make sens, but it should be done at the QMetaTypeId2 Level.
We already do this for const T&, See commit
03b25125986f083a260b421abeed1f1d088d27b3
In fact, the same should be done for const T
> From C++ perspective const T and T are kind of separate types, metatype
> mimics that. QMetaType is used in many places and in some constness
> matters.
>
> Consider that example:
> QMetaType::typeName(qMetaTypeId<const QString>())
> and
> QMetaType::typeName(qMetaTypeId<QString>())
> The function is used in metaobject to compute signatures of invokables.
I can prove you wrong easily, both have the same result, since
QMetaType::normalizedType("const QString") == "QString"
They are different C++ type, yes, but from a practical purpose, their use in
the metatype system is exactly the same. You allocate, destroy or copy a
const QString the same way you do a QString.
--
Olivier
Woboq - Qt services and support - https://woboq.com - https://code.woboq.org
More information about the Development
mailing list