[Interest] Operator QMap<uint, uint>[] is casting to int?
Thiago Macieira
thiago.macieira at intel.com
Sat May 4 17:48:38 CEST 2019
On Saturday, 4 May 2019 05:12:08 PDT Roland Hughes wrote:
> On 5/4/19 5:00 AM, interest-request at qt-project.org wrote:
> >> Unless Qt supports negative indexes (like python's [-1]) I would have
> >> thought this would be an int. Thanks for catching that everyone.
> >
> > I'm assuming you made a typo there and meant to say "uint"? Regardless
> > here's the official reason why Qt uses "int" for container indices:
> > https://lists.qt-project.org/pipermail/interest/2013-September/008592.html
>
> There are an awful lot of places where Qt uses int when it should be
> uint like when returning the size() of something.
Those will likely change to qsizetype in Qt 6. Which is still signed.
> It makes for a lot of
> documentation in the embedded system world where every static_cast<>()
> has to be documented in the code and justified in a formal code review
> which produces even more documentation. It also makes for some fancy
> dancing on 32-bit embedded targets where a uint would be big enough to
> hold the size of something but an int falls short.
No, the size of something definitely fits in int on 32-bit systems. And why do
you need to do any static_cast in the first place?
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel System Software Products
More information about the Interest
mailing list