http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49609

--- Comment #4 from Stephen Kell <srk31 at srcf dot ucam.org> 2011-07-01 
18:09:07 UTC ---
(In reply to comment #2)
> That paragraph says that if template argument deduction succeeds then an
> instantiation is generated. In your case deduction doesn't succeed because the
> target type is not available.  The note added by DR 115 says that the
> specialization can be identified if there's a template argument list, which is
> what happens in your example, but it doesn't say that the function template is
> instantiated in that case.

Ah, I see... I was thinking that the error was spurious because I hadn't
overloaded the function, but I guess the template argument-dependence defines a
family of overloads.

> > You can make it work by using an explicit type conversion to the correct 
> > type
> > before doing the reinterpret_cast:
> > 
> > void *(*my_function_ptr)(void*, void *)
> >  = reinterpret_cast<void*(*)(void*,void*)>(
> >     (void*(*)(float*,float*))&(value_convert_function<float, float>) );
> 
> You can also make it work by not specifying an explicit template argument list
> and letting them be deduced:
> 
> void *(*my_function_ptr)(void*, void *)
>   = reinterpret_cast<void*(*)(void*,void*)>(
>     (void*(*)(float*,float*))&value_convert_function);

Cool -- thanks for this! That teaches me for thinking I can get away without
ever using C-style casts in C++....

Reply via email to