[Issue 2025] Inconsistent rules for instantiating templates with a tuple parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 1 04:55:09 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2025
--- Comment #9 from yebblies <yebblies at gmail.com> 2012-02-01 23:55:06 EST ---
(In reply to comment #8)
> (In reply to comment #7)
> > more specialized == better match. That is how template type deduction works.
>
> But there's no (T : int) version of this template.
>
It doesn't matter.
The compiler does template argument deduction through a function called
matchArg in template.c. It will generate one of the match levels
(MATCHnomatch, MATCHconvert, MATCHconst, MATCHexact) based on what the template
parameter, spectype, and argument are. matchArg does not know or care what the
other overloads of the template are, or even what the other arguments are.
For (T : int) to be preferred over (T), it must return a worse match level for
the unspecialized parameter. Currently it will return MATCHconvert for these
parameters, and return MATCHexact only when there is a (matching) spec type.
Which leaves you with a non-exact match for (T) and (T...), even if it's the
only overload.
--
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