[Interest] QVariantMap: constEnd() not equal to end()?
Hamish Moffatt
hamish at risingsoftware.com
Wed Apr 1 01:35:20 CEST 2015
On 25/03/15 05:16, Thiago Macieira wrote:
> On Tuesday 24 March 2015 17:29:39 Gunnar Roth wrote:
>> Does anybody know why QT_STRICT_ITERATORS is not standard?
> First, because it breaks existing, legitimate code that mixes const and non-
> const iterators properly (yes, there are legitimate ways to do it).
>
> Second, because it's binary incompatible in QVector. The iterator for non-
> strict QVector is a pointer; in strict mode, it's a class. So if you have the
> iterator in your function parameters or template parameters, it will not be
> compatible if you turn it on or off.
>
> However, I do recommend you turn it on in your own code, along with
> QT_NO_CAST_FROM_ASCII and QT_NO_CAST_TO_ASCII.
>
Thanks for the tip. I just enabled QT_STRICT_ITERATORS and fixed a few
bugs. I was bitten by comparison a const_iterator with a non-const end
after upgrading to Qt 5.4 (the same code worked in 4.8).
What's the benefit of QT_NO_CAST_FROM_ASCII though? I tried, but gave up
after I saw the first million compile errors. I converted quite a few
places to use QStringLiteral and QLatin1String, and the debug executable
seemed to grow rapidly (MSVC 2013). Release was barely affected though.
Hamish
More information about the Interest
mailing list