template instantiation --- having trouble therewith

Carl Sturtivant sturtivant at gmail.com
Wed Sep 4 16:32:01 PDT 2013


On Tuesday, 3 September 2013 at 21:52:58 UTC, Manfred Nowak wrote:
> Carl Sturtivant wrote:
>> is supposed to transform one delegate into another
>
> Then please declare the template parameters to be delegates:
>
> U muddle( T, U)( T f) {
> 	uint g( int fp){
> 		return cast(uint)( 5* f( fp));
>         }
> 	auto gP= &g;
> 	return gP;
> }
>
> unittest {
>      import std.stdio;
> 	      int x = 3;
> 	    int scale( int s) { return x * s; }
> 	  auto f= muddle!( int delegate( int), uint delegate( int))( 
> &scale);
> 	writeln( f(7));
> }

But I want some inference. In the real code the relevant 
delegates will have lots of long messy signatures that have 
already been declared.

And in your example above, I want the arguments of the delegates 
in general to be a type tuple, because any delegate may be passed.




More information about the Digitalmars-d-learn mailing list