enum function can't be passed into template?

Zhenya zheny at list.ru
Sun Jan 20 06:21:03 PST 2013


Hi!
Am I doing something wrong?

import std.stdio;

template gun(alias f)
{
	void gun()
	{
		f();
	}
}

void main()
{
	auto str = "hello";
	enum fun = (){writeln(str);};//replace enum -> auto to compile
	gun!fun();
}

Error:delegate c634.main.__lambda1 is a nested function and 
cannot be accessed from c634.gun!(delegate @system void()
{
writeln(str);
}
).gun


More information about the Digitalmars-d-learn mailing list