On Mittwoch, 31. August 2016 08:00:53 CEST Jedrzej Nowacki wrote: > I love to be proven wrong, but this time I would not call it easy [?] Try > this:
We were talking about "T" vs. "const T"; not "T *" vs "const T *". So in your example you should compare "F *" and "F * const" The question whether F* and const F* should have the same metatype is another question worth asking. Since their normalized type does not compare the same anyway, i guess it's ok if they are different. > > > struct F{}; > Q_DECLARE_METATYPE(F*); > Q_DECLARE_METATYPE(const F*); > Q_DECLARE_METATYPE(F); > // Q_DECLARE_METATYPE(const F); doesn't compile, that is a bug! > > class O : public QObject > { > Q_OBJECT > signals: > void foo1(const F*); > void foo2(F*); > }; > > int main(int argc, char **argv) { > qDebug() << QMetaMethod::fromSignal(&O::foo1).methodSignature(); > qDebug() << QMetaMethod::fromSignal(&O::foo2).methodSignature(); > return 0; > } > > > > ________________________________ > From: Development <development-bounces+jedrzej.nowacki=qt...@qt-project.org> > on behalf of Olivier Goffart <oliv...@woboq.com> Sent: Saturday, August 27, > 2016 9:30:21 AM > To: development@qt-project.org > Subject: Re: [Development] Should qMetaTypeId<const T>() == > qMetaTypeId<T>()? > 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 > _______________________________________________ > Development mailing list > Development@qt-project.org > http://lists.qt-project.org/mailman/listinfo/development _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development