digitalmars.D.bugs - [Issue 12117] New: Non-template overload taken when template matches better
- d-bugmail puremagic.com (34/34) Feb 09 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12117
- d-bugmail puremagic.com (15/15) Feb 09 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12117
- d-bugmail puremagic.com (11/11) Feb 09 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12117
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 puremagic.com ReportedBy: peter.alexander.au gmail.com 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: -------
Feb 09 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12117 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 05:12:59 PST --- It likely has to do with the order of operations: 1) Try direct match of: type, then alias this, on regular function 2) Try direct match of: type, then alias this, on templated function (I'm just speculating it works /something/ like this) And the 'alias this' wins before a templated function is tried. I guess it's a question of priority. We'll see what Kenji and others have to say. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 09 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12117 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 5363 *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 09 2014