passing POD by value with const qualifiers. Silly or not?
Ingo Klöcker
kloecker at kde.org
Fri Feb 22 22:23:49 GMT 2008
On Friday 22 February 2008, Stefan Teleman wrote:
> On Fri, Feb 22, 2008 at 3:50 PM, Ingo Klöcker <kloecker at kde.org>
wrote:
> > This is a pretty stupid example, but nevertheless it should
> > illustrate why it might be nice to put a const before a function
> > argument:
> >
> > void f( const int x )
> > {
> > if ( x = -1 ) {
> > return;
> > } else {
> > print( x );
> > }
> > }
>
> if (-1 = x) {
>
> // ...
>
> And, thusly, you don't need const to avoid this one ... :-)
I've tried to use this for some time, but it hurts readability too much
and thus it's not worth the pain. YMMV
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080222/72d2d774/attachment.sig>
More information about the kde-core-devel
mailing list