[Issue 14720] Template function reported as non-template

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


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

--- Comment #5 from Steven Schveighoffer <schveiguy at yahoo.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.

Your code compiles for 2.067 (except for foo).

I also did my own test (which compiles on 2.067 and a recent head version):

void foo()(auto ref int i)
{
}

void bar(T)(auto ref T t)
{
}

void main()
{
    foo!()(1);
    foo(1);
    bar(1);
    bar!int(1);
    alias x = foo!();
    alias y = bar!(int);
    x(1);
    y(1);
}

Which compiles.

OP's code does not. I'm unsure of the rules, or how IFTI is supposed to work,
so I don't want to mark this as rejects-valid, but it sure seems that way.
Perhaps my code is wrong and should be rejected?

--


More information about the Digitalmars-d-bugs mailing list