[Issue 12117] New: Non-template overload taken when template matches better
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 9 04:37:38 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12117
Summary: Non-template overload taken when template matches
better
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: peter.alexander.au at gmail.com
--- Comment #0 from Peter Alexander <peter.alexander.au at gmail.com> 2014-02-09 04:37:36 PST ---
import std.stdio;
struct S
{
int x;
alias x this;
}
void f(T)(T t) { writeln(T.stringof); }
void f(int t) { writeln(int.stringof); }
void main()
{
f(S.init); // f(int) called
}
This writes "int", but should write "S".
The template should be preferred because it matches without implicit
conversions while the non-template requires a conversion. TDPL states that the
non-template should be preferred only when it matches equally well (or better)
than the template.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list