[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: KDE/kdelibs/kdecore
From:       Thiago Macieira <thiago () kde ! org>
Date:       2008-07-08 2:19:59
Message-ID: 200807072319.59832.thiago () kde ! org
[Download RAW message or body]


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

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic