Compile error with QT_STRICT_ITERATORS

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Mon Oct 20 18:54:43 BST 2008


Christian Ehrlicher schrieb:
> Thiago Macieira schrieb:
>> Christian Ehrlicher wrote:
>>> Thiago Macieira schrieb:
>>>> Thiago Macieira wrote:
>>>>> Christian Ehrlicher wrote:
>>>>>> Hi,
>>>>>>
>>>>>>
>>>>>> This code doesn't compile - neither with msvc nor with gcc 3.4.5
>>>>>> (mingw):
>>>>>>
>>>>>> ----------------------------8<------------
>>>>>> #define QT_STRICT_ITERATORS
>>>>>> #include <QtCore/QHash>
>>>>>>
>>>>>> int main(int, char**)
>>>>>> {
>>>>>>   QMultiHash<QString,QString> myHash;
>>>>>>   myHash.remove("blub", "blub");
>>>>>>
>>>>>>   return 0;
>>>>>> }
>>>>>> ----------------------------8<------------
>>>>>>
>>>>>> Looks like a qt-bug to me or do I miss something?
>>>>> There's no QHash::remove(const Key &, const T &);
>>>>>
>>>>> There's only a one-argument QHash::remove.
>>>> Wait, QMultiHash. I missed that.
>>>>
>>>> I see the function there.
>>>>
>>>> But it fails to compile:
>>>> /tmp/multihash/main.cpp:7:   instantiated from here
>>>> src/corelib/tools/qhash.h:336: error: 'bool QHash<Key,
>>>> T>::iterator::operator!=(const QHash<Key, T>::const_iterator&) const
>>>> [with Key = QString, T = QString]' is private
>>>> src/troll/qt-4.5/src/corelib/tools/qhash.h:955: error: within this
>>>> context
>>>>
>>>> Bug in Qt.
>>> Thx, will inform qt-bugs tomorrow :)
>>
>> Fix seems very simple.
>>
>> No need to bother them. Patch attached.
>>
>> I need to get it reviewed tomorrow and then I'll apply to the 4.4 tree.
>>
> ok, I had the same fix but was unsure if it's really correct.
> 
A new one, this time it looks like a problem with gcc 4.3.1/.3 (opensuse):

-------------------------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;".


Ideas?

Christian


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081020/4c99491d/attachment.sig>


More information about the kde-core-devel mailing list