d的双环境指针,弃用

struct MockFile {
  [...]

  void writef(alias fmt, A...)(A args) { 
// 函数要求,弃用了的`双环境`
    import std.format: format;
    write(format!fmt(args));
  }

  [...]
}

unittest {
  auto f = MockFile();
  immutable fmt = "%d";
  f.writef!fmt(0); // 实例化
}

更多细节在此

posted @ 2022-03-02 08:50  zjh6  阅读(14)  评论(0)    收藏  举报  来源