This is the mail archive of the
egcs-bugs@egcs.cygnus.com
mailing list for the EGCS project.
Re: Binding a const reference to a function
- To: EGCS <egcs-bugs@egcs.cygnus.com>
- Subject: Re: Binding a const reference to a function
- From: Valentin Bonnard <Bonnard.V@wanadoo.fr>
- Date: Sun, 04 Jul 1999 11:02:01 +0200
- References: <377F1CB0.6C8E@wanadoo.fr>
Valentin Bonnard wrote:
> quatramaran bonnard ~/C++ $ cat func-as-deduced-param.cc
> void p ();
> template <typename P>
> void bar (const P&);
> void foo ()
> {
> bar(p);
> }
>
> IMO the compiler shouldn't convert p to a void (*) () but it should
> deduce that P = void ().
I think I got it: a function type cannot be const, as in:
$ cat const-function-type.cc
typedef void f ();
f g;
const f& r = g;
$ eg++ -ansi const-function-type.cc -c -o /dev/null
const-function-type.cc:3: `void ()()' cannot be `const'-,
`volatile'-, or `restrict'-qualified
The question is _why_ a function cannot be const, but I
guess it isn't really appropriate here.
--
Valentin Bonnard