Compile error with QT_STRICT_ITERATORS

Thiago Macieira thiago at
Mon Oct 20 19:24:23 BST 2008

Christian Ehrlicher wrote:
>#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;
>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.

  Thiago Macieira  -  thiago (AT) - thiago (AT)
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list