class C { void f(int i)() { } void g() { foreach (i; Range!(1,10)) f!(i)(); } } Error: template instance cannot use local 'i' as parameter to non-global template f(uint i) I think it should work.
The code below works: class C { void f(int i)() { } void g() { foreach (i; Range!(1,10)) h!(i)(this); } } void h(int i)(C c) { c.f!(i)(); } Probably that is only a compiler limitation and can be fixed (or removed) without much effort.
Works now.