July 03, 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 +/
July 03, 2006
Tom S wrote:
> 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;
> }
> 
> 
> 


Bad, Tom.  You've been playing with templates again, haven't you? ;)

-JJR
July 03, 2006
John Reimer wrote:
> Bad, Tom.  You've been playing with templates again, haven't you? ;)

But ... but ... um ... I'm sorry :( /* crosses fingers */ I promise I'll be a good boy ;)


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
1 2
Next ›   Last »