[Issue 1528] [tdpl] overloading template and non-template functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 15 07:27:29 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=1528



--- Comment #30 from Kenji Hara <k.hara.pg at gmail.com> 2013-03-15 07:27:23 PDT ---
(In reply to comment #29)
> (In reply to comment #28)
> > (In reply to comment #26)
> > 
> > It's not about the polysemous literals.
> > What's irritating me is that a function call with conversion
> > is preferred over a function template instantiation with
> > exact arguments.
> > 
> > int f3(long) { return 1; }
> > int f3(T)(T) { return 2; }
> > 
> > int v = 2;
> > f3(v);
> > 
> > MATCHexact / MATCHconvert vs.
> > MATCHconvert / MATCHexact
> 
> IMO the second should be MATCHexact / MATCHexact.

No. type parameter deduction is less specialized than matching to explicitly
specialized type parameter.

void foo(T)(T) {}      // generic version
void foo(T:int)(T) {}  // specialized to int

foo(1);  // calls T:int version

That is why f3(v) makes MATCHconvert / MATCHexact with template version.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list