Passing function(whose parameter would be dynamic and the type is unknown) as a parameter to another function.

Alex sascha.orlov at gmail.com
Sun Jul 8 19:10:24 UTC 2018


On Sunday, 8 July 2018 at 18:46:31 UTC, vino.B wrote:
>  Request you help, in the below code we pass the function 
> "Testfun" as a parameter to another function "process" in order 
> for the function "process" to work we have to specify the type 
> of the parameter that is passed to the function "(T 
> function(string, int) coRoutine, string Test, int Size) ", so 
> now how do we pass a function whose parameter would be dynamic 
> and the type is unknown.

What do you mean with a "function with dynamic parameters" and 
"unknown type"?

But how about

´´´
void main()
{
	process!fun();
}

void process(alias coRoutine, T...)(T params)
{
	coRoutine(params);
}

auto fun(T...)(T params)
{

}
´´´


More information about the Digitalmars-d-learn mailing list