mixin给出了错误

时间:2012-01-05 13:58:36

标签: d dmd

位于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)

是我的还是他们的错误?

1 个答案:

答案 0 :(得分:9)

文字已过时。将char[]替换为string即可。