[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-22 16:23:26
Message-ID: 1ccb59a20802220823t7204efc9q1880394f3c4dc381 () mail ! gmail ! com
[Download RAW message or body]

On Fri, Feb 22, 2008 at 8:28 AM, André Wöbbeking <Woebbeking@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@gmail.com

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

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