[Issue 14720] Template function reported as non-template

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jun 22 18:17:56 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14720

--- Comment #4 from Yuxuan Shui <yshuiv7 at gmail.com> ---
(In reply to Kenji Hara from comment #3)
> (In reply to Yuxuan Shui from comment #2)
> > Seems this bug is not related to nested templates at all, it's more likely
> > an 'auto ref' bug:
> 
> `auto ref` parameter is allowed for template functions, AND needs actual
> function argument to deduce its ref-ness. For example:
> 
> void foo(auto ref int x) {}    // non-template function
> // -> NG, auto can only be used for template function parameters
> 
> void bar(T)(auto ref T x) {}
> void main() {
>     int n;
> 
>     // IFTI (implicit function template instantiation)
>     bar(1);      // OK, parameter x is deduced to non-ref
>     bar(n);      // OK, parameter x is deduced to ref
> 
>     // partial template specialization + IFTI
>     bar!int(1);  // also OK, equivalent with bar(1)
>     bar!int(n);  // also OK, equivalent with bar(n)
> 
>     // explicit instantiation without IFTI
>     alias b = bar!int;
>     // NG! auto ref parameter x cannot deduce its ref-ness, therefore
>     // sole auto ref parameter is rejected as same as foo definition.
> }

At least the error message here needs some improvement. 

Besides, this still doesn't work even if I call them in devil().

--


More information about the Digitalmars-d-bugs mailing list