[Development] QCOMPARE & mixed types

Lars Knoll lars.knoll at qt.io
Fri Apr 21 13:29:08 CEST 2017


On 21 Apr 2017, at 12:53, Konstantin Tokarev <annulen at yandex.ru<mailto:annulen at yandex.ru>> wrote:



21.04.2017, 13:45, "Milian Wolff" <milian.wolff at kdab.com<mailto:milian.wolff at kdab.com>>:
On Freitag, 21. April 2017 12:10:07 CEST Marc Mutz wrote:
 Hi,

 Jedrzej asked me to raise the issue here.

 Rationale for both allowing, as well as for why I think the rationale for
 the existing ban is wrong, is included in the commit message:

   https://codereview.qt-project.org/192269

I for one welcome this change. I always cringed when I wrote code such as

    QCOMPARE(getSomeQUint64(), 0)

and it would fail to compile, forcing me to write ugly code such as

    QCOMPARE(getSomeQUint64(), quint64(0))

I've also come across code that failed to compile some platforms, since it
used something like 0l or 0ll which did not match whatever platform-specific
type was used on the lhs...

So, from my side a clear +1!

Another case: comparing QString or QByteArray on one side with const char*
literal, or with expression which returns QStringBuilder

Implicit conversions from QByteArray/const char * to QString was one of the reasons we didn't want this in the past (Qt 4), as those conversions were locale dependent. That is of course less of a problem since Qt 5.0.

Cheers,
Lars



--
Milian Wolff | milian.wolff at kdab.com<mailto:milian.wolff at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
,

_______________________________________________
Development mailing list
Development at qt-project.org<mailto:Development at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/development

--
Regards,
Konstantin
_______________________________________________
Development mailing list
Development at qt-project.org<mailto:Development at qt-project.org>
http://lists.qt-project.org/mailman/listinfo/development

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170421/af4897e1/attachment.html>


More information about the Development mailing list