Compile error with QT_STRICT_ITERATORS

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Mon Oct 20 19:44:32 BST 2008


Thiago Macieira schrieb:
> Christian Ehrlicher wrote:
>> -------------------------8<---------------------
>> #define QT_STRICT_ITERATORS 1
>> #include <QtCore/QMap>
>> #include <QtCore/QString>
>>
>> int main(int, char**)
>> {
>>    QMap<QString, QString> strMap;
>>    QMap<QString, QString>::const_iterator it = strMap.find("blub");
>>
>>    return 0;
>> }
>> -------------------------8<---------------------
>>
>> Somehow gcc won't use "const_iterator find(const Key &key) const;".
> 
> That's normal. The selection of the overload is not done by the return 
> type. So the compiler always selects “iterator find(const Key &key)” if 
> strMap isn't const. Then you get the conversion error afterwards.
> 
> Use constFind.
> 
Ok - this means I've to fix much more places than I thought or stop my 
QT_STRICT_ITERATORS experiment.
Now I wonder why msvc doesn't complain and seems touse the const one 
instead.


Christian




More information about the kde-core-devel mailing list