[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:       "Stefan Teleman" <stefan.teleman () gmail ! com>
Date:       2008-02-23 17:26:41
Message-ID: 1ccb59a20802230926p76511a7ex81a34e87b41950d7 () mail ! gmail ! com
[Download RAW message or body]

On Sat, Feb 23, 2008 at 4:48 AM, Friedrich W. H. Kossebau
<kossebau@kde.org> wrote:

>  Well, now that I think about this... the later version has it's pro, too.
>  Because "to" in the first version is non-const also for the rest of the
>  function and not protected against unwanted assignments, while in the second
>  it is, if one uses toValueWhichIsValid. Hm. What is the best practise here?

If you really really really need all this const magic juju, use
by-const-reference instead of by-const-value.
It will satisfy all your constness requirements and it will not allow
you to mismatch constness declaration vs. definition. And it will make
the intent very clear just from reading the function declaration.

--Stefan (a member of the by-const-value-is-illegal-in-13-states
monitoring group)

-- 
Stefan Teleman
KDE e.V.
stefan.teleman@gmail.com
[prev in list] [next in list] [prev in thread] [next in thread] 

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