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

Stefan Teleman stefan.teleman at gmail.com
Fri Feb 22 16:23:26 GMT 2008


On Fri, Feb 22, 2008 at 8:28 AM, André Wöbbeking <Woebbeking at kde.org> wrote:

>  Did you try it? According to the C++ standard e.g.
>
>  void foo(int);
>  void foo(const int);
>
>  are equivalent.

Tried it and dealt with it many many times.

ISO/IEC:14882:2003:13.1

Overloadable declarations

[ ... ] const and volatile type-specifiers buried within a parameter
type specification are significant and can be used to distinguish
overloaded function declarations. [ ... ]

One could argue that overloading on the const or volatile type
specifier was intended for pointer or reference types only [hi,
comp.std.c++.moderated!], but Sun Studio has enforced the overloading
distinction between void foo(int) and void foo(const int) since i can
remember.

The question still remains (in my mind): why is void foo(const int)
useful ? It's not like there are any amazing assembler optimizations
possible when saying void foo(const int) as opposed to just void
foo(int).

--Stefan

--
Stefan Teleman
KDE e.V.
stefan.teleman at gmail.com


More information about the kde-core-devel mailing list