template mixins for boilerplate

Philippe Sigaud via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 20 22:52:28 PDT 2014


Use a string mixin?

string fun(string name)
{
  return "public static int " ~ name ~ "() { return 0; }";
}

struct S {
    mixin (fun("fctn1"));
}

void main() {
    S s;
    import std.stdio;
    writeln(s.fctn1());
}


More information about the Digitalmars-d-learn mailing list