scope exit in mixin template

Byron via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 8 11:28:25 PDT 2014


Can we not use scope(..) in a mixin template?

struct bar {}
bar* c_make() { return new bar(); }
void c_free(bar* b) { b = null; }

mixin template Foo() {
  auto b = c_make;
  scope(exit) if(b) c_free(b);
}

void main() {
  mixin Foo;
}

I get Error: Declaration expected, not '('

-Byron





More information about the Digitalmars-d-learn mailing list