1

示例位于:http ://www.d-programming-language.org/mixin.html ,如下所示:

template GenStruct(char[] Name, char[] M1) {
    const char[] GenStruct = "struct " ~ Name ~ "{ int " ~ M1 ~ "; }";
} mixin(GenStruct!("Foo", "bar"));

“生成:”(根据网站):

struct Foo { int bar; }

给我一个错误:

Error: template instance GenStruct!("Foo","bar") GenStruct!("Foo","bar") does not match template declaration GenStruct(char[] Name,char[] M1)

是我的还是他们的虫子?

4

1 回答 1

9

文本已过时。替换char[]string,它会工作。

于 2012-01-05T14:02:06.383 回答