This is the mail archive of the egcs-bugs@egcs.cygnus.com mailing list for the EGCS project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Binding a const reference to a function


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]