template instantiation --- having trouble therewith

Carl Sturtivant sturtivant at gmail.com
Wed Sep 4 16:34:36 PDT 2013


On Tuesday, 3 September 2013 at 17:25:12 UTC, Manfred Nowak wrote:
> 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

This technique does what I want if there's a single parameter to 
the delegate. I'll explore from here; thanks for all the examples.

Carl.



More information about the Digitalmars-d-learn mailing list