digitalmars.D.bugs - [Issue 1383] New: Implicit Function Instantiation with typesafe-variadic of delegates doesn't work
- d-bugmail puremagic.com (72/72) Jul 27 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1383
- d-bugmail puremagic.com (14/14) Mar 11 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1383
- d-bugmail puremagic.com (9/9) Jun 22 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1383
- d-bugmail puremagic.com (8/8) Jun 23 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1383
- d-bugmail puremagic.com (9/9) Jan 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=1383
http://d.puremagic.com/issues/show_bug.cgi?id=1383 Summary: Implicit Function Instantiation with typesafe-variadic of delegates doesn't work Product: D Version: 1.020 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: webmaster villagersonline.com I have a template function, with a single Tuple template parameter, where the arguments to the function are typesafe variadic delegates, where each delegate takes arguments defined by the Tuple. It will not implicitly deduce the elements of the Tuple: CODE ================ /* parts of Curry() taken from the digitalmars.com template examples */ void delegate(U) Curry(A, U...)(void delegate(A,U) dg,A arg) { struct ArgRecord { A arg; typeof(dg) callback; void OpCall(U args) { callback(arg,args); } } auto temp = new ArgRecord; temp.arg = arg; temp.callback = dg; return &temp.OpCall; } /* the intent of this template is to take 2 or more delegates with the * the same argument types and return a new delegate which will call * each delegate in sequence, passing it the arguments delivered. */ void delegate(A) Seq(A...)(void delegate(A)[] dgs...) { return Curry(delegate void(void delegate(A)[] dgs1,A args) { foreach(dg; dgs1) dg(args); }, dgs); } struct Foo { void fred(int i) {} } void main() { void delegate(int) tmp; auto bob = new Foo; auto dan = new Foo; tmp = Seq!(int)(&bob.fred); // this works tmp = Seq!(int)(&bob.fred, &dan.fred); // this works tmp = Seq (&bob.fred); // this doesn't tmp = Seq (&bob.fred, &dan.fred); // neither does this } ========= DMD OUTPUT: ========= baz.d(45): template baz.Seq(A...) does not match any template declaration baz.d(45): template baz.Seq(A...) cannot deduce template function from argument types (void delegate(int)) baz.d(45): Error: cannot implicitly convert expression ((Seq(A...))((&(*bob).fred))) of type int to void delegate(int) baz.d(46): template baz.Seq(A...) does not match any template declaration baz.d(46): template baz.Seq(A...) cannot deduce template function from argument types (void delegate(int),void delegate(int)) baz.d(46): Error: cannot implicitly convert expression ((Seq(A...))((&(*bob).fred),(&(*dan).fred))) of type int to void delegate(int) Note that the template works fine if I explicitly instantiate it. --
Jul 27 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1383 ------- Comment #1 from wbaxter gmail.com 2008-03-11 16:34 ------- Actually it's much simpler than all that. IFTI with plain old typesafe variadic doesn't work. void foo(T)(T[] x ...) { } void main() { foo(2,7,4); } iftivariadic.d(23): template iftivariadic.foo(T) does not match any function template declaration iftivariadic.d(23): template iftivariadic.foo(T) cannot deduce template function from argument types !()(int,int,int) --
Mar 11 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1383 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla digitalmars.com 2008-06-22 18:52 ------- Fixed dmd 1.031 and 2.015 --
Jun 22 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1383 webmaster villagersonline.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED ------- Comment #3 from webmaster villagersonline.com 2008-06-23 12:14 ------- Fix confirmed. --
Jun 23 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1383 Andrei Alexandrescu <andrei erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|VERIFIED |RESOLVED CC| |andrei erdani.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 26 2013