digitalmars.D.bugs - [Issue 2803] New: template + default argument = doesn't work
- d-bugmail puremagic.com (26/26) Apr 05 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2803
- d-bugmail puremagic.com (20/20) Apr 05 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2803
- d-bugmail puremagic.com (12/12) Apr 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=2803
http://d.puremagic.com/issues/show_bug.cgi?id=2803 Summary: template + default argument = doesn't work Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com struct S {} ref S getS(); void fun(T, U)(T t, ref U u = getS) { } void main() { fun(1); } ./test.d(10): Error: template test.fun(T,U) does not match any function template declaration ./test.d(10): Error: template test.fun(T,U) cannot deduce template function from argument types !()(int) --
Apr 05 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2803 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com OS/Version|Linux |All I'm not sure that this is supposed to work. It would appear that the process of binding template parameters to arguments happens strictly before that of applying default arguments. Moreover, even if U is given, if it's anything but S then it triggers a type mismatch on the default argument. It would appear that you need two templates void fun(T)(T t) { fun(t, getS()); } void fun(T, U)(T t, U u) { } --
Apr 05 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2803 Martin Nowak <code dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code dawg.eu To me it looks like it should work. When the arity requires it, the default argument should be added to the list of function arguments before deducing the template arguments. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 14 2013