Search code examples
ddmd

mixin gives error


The example at: http://www.d-programming-language.org/mixin.html, appears below:

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

"which generates:" (according to the site):

struct Foo { int bar; }

gives me an error:

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

Is it mine or their bug ?


Solution

  • The text is outdated. Replace char[] with string and it'll work.