位于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)
是我的还是他们的错误?
答案 0 :(得分:9)
文字已过时。将char[]
替换为string
即可。