[Issue 1528] [tdpl] overloading template and non-template functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 14 08:46:47 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=1528
--- Comment #24 from Martin Nowak <code at dawg.eu> 2013-03-14 08:46:43 PDT ---
(In reply to comment #23)
I think this rule is problematic for the function vs. deduced parameter case.
// vs deduced parameter
int f3(int a) { return 1; }
int f3(T)(T b) { return 2; }
f3(1L);
With first overload version,
Phase 1: normal function is treated as having empty template parameter list, so
matching is always exact ==> MATCHexact
Phase 2: int <- 1L == MATCHconvert ==> MATCHconvert
With second overload version,
Phase 1: T <- typeof(1L) = long ==> MATCHconvert
Phase 2: T <- 1L == MATCHexact ==> MATCHexact
- the current implementation in the pull request chooses
the function whereas comment #13 and #16 suggest to go
with the function template
https://github.com/9rnsr/dmd/blob/b141e29e29b1ec43873c7e0374d27d3fbbae8085/test/runnable/overload.d#L216
https://github.com/9rnsr/dmd/blob/b141e29e29b1ec43873c7e0374d27d3fbbae8085/test/runnable/overload.d#L279
- C++ chooses the function template
- For me it's counterintuitive to call with conversion when an exact
match can be instantiated. Even an ambiguous error seems more reasonable to
me.
--
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