template instantiation --- having trouble therewith

Manfred Nowak svv1999 at hotmail.com
Tue Sep 3 10:25:12 PDT 2013


Carl Sturtivant wrote:
> Writing muddle!(int,int)
[...]
> gives the same error message.

Not entirely true:

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

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

-manfred


More information about the Digitalmars-d-learn mailing list