[Issue 5710] cannot use delegates as parameters to non-global template

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 10 05:49:05 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=5710

--- Comment #33 from Sobirari Muhomori <dfj1esp02 at sneakemail.com> ---
A slightly more straightforward solution: the passed context is effectively a
closure, and it can contain any variables, so let's just pass this pointer in
the closure context struct. All the rules of closures apply.

struct main_add_closure_context
{
  auto var1;
  auto var2;
  Foo foo_this;
  auto var3;
  auto var4;
}

This context is like any normal closure, the `add` can simply use it. Also pass
it instead of `this` argument to doStuff(alias fun), which in its turn should
be taught to get `this` reference from the passed context struct.

--


More information about the Digitalmars-d-bugs mailing list