A New Krazy Checker for Methods Returning const refs

Simon Hausmann hausmann at kde.org
Mon Apr 16 11:35:33 BST 2007


On Monday 16 April 2007 10:20:58 Mirko Boehm wrote:
> It is a Qt-ism that return values are supposed to be thread safe. It is
> declaredly not a policy for C++. It is, in fact, the other way around: The
> standard library classes are not syncronized, it is left to the classes
> that use them to take care of that.
>
> Whether a method returns a copy or a const reference is not only a matter
> of the cost of the copying, but also of the implementation of the class
> itself. For example, if a class holds a cached value in a member variable,
> even the cheap refcounted copy operation is a waste of time.
>
> I oppose this policy. It makes writing classes harder, since we have to
> continuously distinguish between standard library classes and our own. And
> I have a hard time seeing the benefits.

I believe the convenience and safety of the code that /uses/ the classes as 
well as the flexibility of being able to change the implementation in the 
library in the future without breaking compatibility outweights the ease of 
writing the library code.


Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070416/fbc4d19e/attachment.sig>


More information about the kde-core-devel mailing list