template instantiation --- having trouble therewith

Carl Sturtivant sturtivant at gmail.com
Mon Sep 2 20:49:50 PDT 2013


template Dptr( T, U...) {
	alias T delegate( U args) Dptr;
}

Dptr!(T,U) muddle( T, U...)( Dptr!(T,U) f) {
	return f; //or make another delegate in real code
}


unittest {
	import std.stdio;
	int x = 3;
	int scale( int s) { return x * s; }
	Dptr!(int,int) f = muddle( &scale);
	writeln( f(7));
}
============================================

The above technique seemed natural to me, but I get this message 
from dmd:

p1.d(15): Error: template p1.muddle does not match any function 
template declaration. Candidates are:
p1.d(7):        p1.muddle(T, U...)(Dptr!(T, U) f)
p1.d(15): Error: template p1.muddle(T, U...)(Dptr!(T, U) f) 
cannot deduce template function from argument types !()(int 
delegate(int))

and if I use muddle!(int,int) instead it doesn't help. This is 
likely a misunderstanding on my part --- please show me how to 
sort this out.



More information about the Digitalmars-d-learn mailing list