xxxxxxxxxx
import std.stdio;
import std.traits;
auto assumeNoGC(T)(return scope T t) {
import std.traits;
enum attrs = functionAttributes!T | FunctionAttribute.nogc;
return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
}
private struct Dispatcher {
public template opDispatch(string name){
auto ref opDispatch(Args...)(auto ref Args args) {
//assumeNoGC({ writefln("%d", 42); })(); // This works now
debug {
writefln("%d", 42);
}
return 3;
}
}
}
void main() {
auto i = Dispatcher().getI(3);
}