thiago at kde.org
Tue Jul 8 03:19:59 BST 2008
Andreas Pakulat wrote:
>I'm not sure why the const_this is needed here anyway, shouldn't a
> simple const_iterator and ::constEnd() be sufficient too?
It's needed because of the missing constFind() function. There are two
overloads to find(): one non-const returning an iterator and a const
returning a const_iterator. The only way to select the const version (and
hence avoid detaching) is to have a const container.
That is accomplished by having a const KMacroMapExpander, because that
makes its member variables also const.
In general, mixing iterators is bad and can lead to errors. Qt provides a
macro (QT_STRICT_ITERATORS) that will make comparisons between iterators
and const_iterators fail, so you catch those mistakes.
Also, if you took foo.find(), you should use foo.end() [which is what your
patch does], instead of taking another path to "foo".
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the kde-core-devel