On Friday, 10 August 2018 at 13:05:24 UTC, Kagamin wrote:
Mixim template can only introduce declarations, not statements,
a workaround is a lambda called in place.
mixin template test(A...){
__gshared a = A;
int dummy = (){ a++; return 0; }();
}
extern(C) void main(){
mixin test!123;
}
Except that you can't use tuples for that, a working sample:
mixin template test(alias A){
__gshared a = A;
int dummy = (){ a++; return 0; }();
}
extern(C) void main(){
mixin test!123;
import core.stdc.stdio;
printf("%d", a);
}