Topic: Quick question about const function parameters
Author: "Gary Hinger" <garyh@zipperint.com>
Date: 2000/10/20 Raw View
Please tell me if am right (and that VS6 is wrong). Defining a function's
parameter to be const is completely irrelevant except in the actual
implementation. Thus, the following should work according to the Standard.
Thanks.
void foo( void (*)(int) );
void bar( int const );
void test() {foo( bar );}
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: comeau@panix.com (Greg Comeau)
Date: Sun, 22 Oct 2000 03:23:42 GMT Raw View
In article <39ef6c88$1_2@news.nwlink.com>,
Gary Hinger <garyh@zipperint.com> wrote:
>Please tell me if am right (and that VS6 is wrong). Defining a function's
>parameter to be const is completely irrelevant except in the actual
>implementation.
Right, at the top level that is.
>Thus, the following should work according to the Standard.
>
>void foo( void (*)(int) );
>void bar( int const );
>
>void test() {foo( bar );}
Yes. Actually, it doesn't seem to come into play in this example
no matter what.
- Greg
--
Comeau Computing / Comeau C/C++ "so close" 4.2.44 betas NOW AVAILABLE
TRY Comeau C++ ONLINE at http://www.comeaucomputing.com/tryitout
Email: comeau@comeaucomputing.com / WEB: http://www.comeaucomputing.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: juergen@monocerus.n-online.de (Juergen Heinzl)
Date: 2000/10/22 Raw View
In article <39ef6c88$1_2@news.nwlink.com>, Gary Hinger wrote:
>Please tell me if am right (and that VS6 is wrong). Defining a function'=
s
>parameter to be const is completely irrelevant except in the actual
>implementation. Thus, the following should work according to the Standar=
d.
>Thanks.
>
>void foo( void (*)(int) );
>void bar( int const );
>
>void test() {foo( bar );}
[-]
8.3.5 Functions
---------------
3) ...=20
Any cv-qualifier modifying a parameter type is deleted. [Example:
the type void (*)( const int) becomes void (*)(int) -- end example]
Such cv-qualifiers affect only the definition of the parameter within
the the body of the function; they do not affect the function type.
...
Cheers,
Juergen
--=20
\ Real name : J=FCrgen Heinzl \ no flames /
\ EMail Private : monocerus@n-online.de \ send money instead /
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]