Aliases of member functions in template arguments
Please include the example module as a whole. This compiles and correctly runs, so I'm not sure what you're talking about:
import std.stdio, std.meta;
struct S {
void f() { }
}
void t(alias f)() { writeln ("hello world"); }
void main()
{ S s;
alias f = s.f;
t!(s.f);
}
I have edited the DIP to show the error more exactly. Here is a copy of the example with the error:
import std.stdio, std.meta;
struct S {
void f() { }
}
void t(alias f)() { f(); writeln ("hello world"); }
void main()
{
S s;
t!(s.f); // does not compile
}
You can already do what you want with a bit extra syntax:
import std.stdio, std.meta;
struct S {
void f() { }
}
void t(alias f)() { f(); writeln ("hello world"); }
void main()
{
S s;
t!(() => s.f); // now compiles
}
Of course, this is slightly more verbose, but personally I think it's better to require explicit syntax here. The reason is that you are creating a closure here (t needs to know the address of S s), which means heap and garbage collector usage. I would not like that to be too invisible.