Problems with implicit template instantiation: Tail Currying
Russell Lewis
webmaster at villagersonline.com
Wed Jul 18 11:55:50 PDT 2007
I'm trying to write a template to perform function currying of the
*last* argument to a delegate, and I can't get implicit instantiation to
work with my template. Take a look at this example code:
=======
void delegate(U) Curry (A,U...)(void delegate(A,U) dg,A arg) {
return delegate void(U) {};
}
void delegate(U) CurryTail(A,U...)(void delegate(U,A) dg,A arg) {
return delegate void(U) {};
}
void foo() {
void delegate(uint,char[],uint) dg;
uint i;
Curry (dg,i);
CurryTail(dg,i);
}
=======
The CurryTail call fails with the following errors:
foo.d(11): template foo.CurryTail(A,U...) does not match any template
declaration
foo.d(11): template foo.CurryTail(A,U...) cannot deduce template
function from argument types (void delegate(uint, char[], uint),uint)
So: if the Curry() call works, why doesn't the CurryTail() call? Is
this a bug, or some sort of design restriction?
Russ
More information about the Digitalmars-d
mailing list