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

--- Comment #31 from Marc Glisse <marc.glisse at normalesup dot org> 2011-08-31 
13:40:28 UTC ---
(In reply to comment #25)
> (In reply to comment #23)
> > I think you can do it with a alias-declaration in an extern "C" block:
> > 
> > extern "C" {
> >   template<typename T>
> >     using func_type = T (*)();
> > }
> > 
> > extern "C" void c() { }
> > 
> > template<typename T>
> >   void f( func_type<T> p ) { p(); }
> > 
> > int main()
> > {
> >   f(&c);
> > }
> > 
> > But yes, it's a bit of a hole in the type system that language linkage is 
> > part
> > of the type but can only be specified in some contexts and can't be deduced 
> > by
> > templates.
> 
> Yes, I thought about the alias, but it doesn't deduce the type. I really don't
> think your example works unless you call f<thetype>(&c) as aliases are not
> supposed to be deduced.

Sorry for that comment, I was completely wrong because of a gross
misunderstanding of template aliases, your solution is great (as soon as gcc
has template aliases ;-).

http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/43df1e789d3b44fe

Reply via email to