== Quote from Torarin (torar...@gmail.com)'s article
> 2011/1/23 Sean Eskapp <eatingstap...@gmail.com>:
> > I want to be able to access the enclosing scope, but NOT after the function 
> > has
> > exited; I should have the option of accessing the enclosing scope, but at 
> > the cost
> > of making my delegate not a closure.
> >
> Until we have a dedicated syntax for it, I think you can use this hack:
> import std.traits;
> auto scopeDelegate(D)(scope D d) if (isDelegate!D)
> {
>   return d;
> }
> int main()
> {
>    StructWithDtor s;
>    trustedFunction(scopeDelegate({s.a = 5;}); // No heap allocation
> }
> Torarin

Yup, works great with everything I've tried! Thanks.

Reply via email to