d的构闭包

struct FunctionObject {
  string s;

  this(string s) {
    this.s = s;
  }

  auto opCall() {
    import std.stdio : writeln;
    s.writeln;
  }
}

struct A
{
    FunctionObject[] dg;
}

auto createDelegate(string s) {
  return FunctionObject(s);
}
posted @ 2021-12-08 11:10  zjh6  阅读(13)  评论(0)    收藏  举报  来源