Thiago Macieira thiago at kde.org
Mon Sep 15 21:29:20 BST 2008

Michael Jansen wrote:
>Has the const any kind of effect? Itcould be there to prevent the
> calling code to change the list it gets, but still allow to change the
> actions? So no adding and removing of actions

We have started doing that in Qt: when we return a non-POD object, we 
sometimes return it const.

We're not doing that consistently, but maybe we should.

For example, the code:


where someMethod() returns QString, is allowed, but shouldn't be because 
the result is discarded at the ;

The same goes for QList and methods like operator[], takeFirst, takeLast, 
etc. And even improves code like:

	Type t = function()[i];

if function() returns const QList, that'll call operator[](int) const, 
whereas if it isn't const, it'll call the non-const version of 
operator[], that does an implicit detach.

  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...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080915/4800874b/attachment.sig>

More information about the kde-core-devel mailing list