template interface and delegates

anonymous non at trash-mail.com
Mon Mar 31 11:58:30 PDT 2014


Hi,
I'm new to D and played a bit with templates and delegates.
Now i discovered some behaviore that i don't understand.
Can somebody explain me why i get two different outputs?


import std.stdio;


interface A(T){
	bool GetBool();
	T getT();
}

class C:A!(double){
	override bool GetBool(){
		return false;
	}
	override double getT(){
		return 1;
	}
}

void mwriteln(T)( A!T delegate() dg){
	writeln(dg().getT());
}

void main()
{
	auto c = new C();
	writeln(c.getT());
	mwriteln!double({return new C();});
}


More information about the Digitalmars-d-learn mailing list