weird behavior returning delegate

Tom S h3r3tic at remove.mat.uni.torun.pl
Mon Jul 3 10:59:03 PDT 2006


Or for the extremists...


T delegate(T a) acc(T)(T i){
	struct Foo {
		T a;
		T func(T x) { return a += x; }
	}
	return &(cast(Foo*)((&i)[0..1]).dup).func;
}

or...

T delegate(T a) acc(T)(T i){
	struct Foo {
		T a;
		T func(T x) { return a += x; }
	}
	return &(cast(Foo*)((new T[1])[] = i)).func;
}



-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/



More information about the Digitalmars-d mailing list