[Development] qsizetype and classes working with QStrings or QList

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Aug 25 19:48:12 CEST 2020

On 25/08/2020 02.22, Mathias Hasselmann wrote:
> I'd really enjoy implementing list models without having 
> to litter static casts all over the place. Well, but seems that chance 
> got missed once again with qsizetype still being signed.

That's intentional. There are problems with unsigned index types, not 
least of which is they aren't practically useful anyway. Some consider 
it a mistake that size_t is unsigned, and indeed, ssize_t is starting to 
be retrofitted in some places (e.g. `container.ssize()`). If we ever get 
an STL2 it will likely also have signed index types.

Signed index types allow things like indexing-from-end and make tests 
for invalid indices far less painful. Seriously, which of these do you 

   if (s.find(ch) < 0)                   // option 1
   if (s.find(ch) != std::string::npos)  // option 2


More information about the Development mailing list