This is the best I came up with:
auto staticMappedCall(alias call, alias F, T...)(T t) { T a; foreach(i, arg; t) a[i] = F(arg); return call(a); }
You use it as follows:
staticMappedCall!(bar,t)(1, 2);
Where bar is a call function and t is a transform.
void bar(int a, int b) { writeln(a, " ", b); } int t(int a) { return a*2; } staticMappedCall!(bar, t)(1, 2); > test 2 4
Adam D. Ruppe
source share