delegate, template and alias

Heromyth bitworld at qq.com
Sun Dec 18 05:13:08 PST 2011


I have a delegate as a parameter in a function which is a template function.
And I want to use alias for the delegate parameter.
Is there a better way for this?

My demo code:

template AsynchronousAction(T)
{
	alias void delegate(T argument) FuncType;
}

public class TestC
{
	int b = 3;

	//void test(T)(void delegate(T argument) func )
	void test(T)(AsynchronousAction!(T).FuncType func )
	{
		static if(is(T == string))
		func("It's me");
	}

	this(int x)
	{
		b = x;
	}
}


More information about the Digitalmars-d-learn mailing list