dmd v2.074.0 on ubuntu 14.04
-------------------
import std.traits: Parameters;
void f(int x) {}
void wrap1(R, T...)(R function(T) fn, T args) {}
void wrap2(alias F)(Parameters!F args) {}
void wrap3(F)(F fn, Parameters!F args) {}
void wrap4(F)(F* fn, Parameters!F args) {}
void main() {
int x;
wrap1(&f, x); // ok
wrap2!f(x); // ok
wrap3(&f, x); // Error: template wrap3 cannot deduce function from argument types !()(void function(int x), int), candidates are:
// wrap3(F)(F fn, Parameters!F args)
wrap4!(typeof(f))(&f, x); // ok -- explicit typeof
wrap4(&f, x); // same error
}
Comment #1 by tomer — 2017-05-16T06:19:26Z
the first version (wrap1) would have been OK, but it cannot be used with `ref`/`scope`/`lazy` etc, as these would be lost when using `T...`. so
void f(ref int x) {}
int x;
wrap1(&f, x); // void function(int) != void function(ref int)
Comment #2 by dlang-bugzilla — 2017-05-16T07:02:02Z
Mixing IFTI arguments and arguments derived from IFTI arguments is currently not supported. (It was surely reported before in another issue.)
A workaround is:
void wrap5(F, Args...)(F fn, Args args) if (is(Args == Parameters!F)) {}
wrap5(&f, x);
> void f(ref int x) {}
> int x;
> wrap1(&f, x); // void function(int) != void function(ref int)
Just for ref, "auto ref" usually suffices.
BTW, I noticed you added the industry keyword. If you haven't already, consider adding your company to http://dlang.org/orgs-using-d.html.
Comment #3 by tomer — 2017-05-16T07:15:45Z
I'm from weka (updated my email to the company's email thanks to your advice)