passing POD by value with const qualifiers. Silly or not?

Stefan Teleman stefan.teleman at
Sat Feb 23 17:26:41 GMT 2008

On Sat, Feb 23, 2008 at 4:48 AM, Friedrich W. H. Kossebau
<kossebau at> 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 at

More information about the kde-core-devel mailing list