fork download
  1. import std.stdio;
  2. import std.string;
  3.  
  4. template Foo(string Head)
  5. {
  6. mixin("int " ~ Head ~ ";");
  7. }
  8.  
  9. template Foo(string Head, Tail...)
  10. {
  11. mixin Foo!Head;
  12. mixin Foo!Tail;
  13. }
  14.  
  15. struct Bar(Params...)
  16. {
  17. mixin Foo!Params;
  18. }
  19.  
  20. void main()
  21. {
  22. Bar!("hello", "world") bar;
  23. bar.hello = 10;
  24. bar.world = 20;
  25. writeln(bar.hello, " ", bar.world);
  26. }
  27.  
Success #stdin #stdout 0.01s 2120KB
stdin
Standard input is empty
stdout
10 20