https://issues.dlang.org/show_bug.cgi?id=4215
RazvanN <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |[email protected] Resolution|--- |WONTFIX --- Comment #5 from RazvanN <[email protected]> --- This code compiles: void bar(T)(auto ref T item) { } void main() { int i; bar!(int)(i); } This code also compiles: template bar(T) { void bar(auto ref T item) { } } void main() { int a; bar(2); bar(a); } This, however, does not compile: class Foo(T) { void bar(auto ref T item) { } } void main() { Foo!(int) f; } And it cannot compile since once you instantiate Foo the compiler needs to know how to instantiate bar. Since bar is not a templated function the compiler cannot resolve `auto ref` and therefor correctly outputs the error that `auto ref` parameters are allowed only for templated functions. The easy fix is to template bar. This enhancement request is invalid. --
