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

List:       kde-core-devel
Subject:    Re: passing POD by value with const qualifiers. Silly or not?
From:       Ingo =?utf-8?q?Kl=C3=B6cker?= <kloecker () kde ! org>
Date:       2008-02-22 22:23:49
Message-ID: 200802222323.49589 () erwin ! ingo-kloecker ! de
[Download RAW message or body]


On Friday 22 February 2008, Stefan Teleman wrote:
> On Fri, Feb 22, 2008 at 3:50 PM, Ingo Klöcker <kloecker@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

["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