July 03, 2006 Re: weird behavior returning delegate | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Chris Nicholson-Sauls | 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 Re: weird behavior returning delegate | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tom S | 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 Re: weird behavior returning delegate | ||||
|---|---|---|---|---|
| ||||
Posted in reply to John Reimer | 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 +/ | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply