Re: Pass template parameter into q{} string

2019-04-08 Thread Kagamin via Digitalmars-d-learn
Maybe just use mixin template? mixin template f(alias values) { static foreach(v;values) mixin("bool " ~ v ~ " = false;"); } int main() { enum string[] a=["a","b"]; mixin f!a; return 0; }

Re: Pass template parameter into q{} string

2019-04-02 Thread Marco de Wild via Digitalmars-d-learn
On Monday, 1 April 2019 at 17:32:29 UTC, Andrey wrote: Hello, enum Key : string { First = "qwerty", Last = "zaqy" } void main() { enum decl(alias values1) = q{ static foreach(value; values1) mixin("bool " ~ value ~ " = false;"); }; enum qqq =

Pass template parameter into q{} string

2019-04-01 Thread Andrey via Digitalmars-d-learn
Hello, enum Key : string { First = "qwerty", Last = "zaqy" } void main() { enum decl(alias values1) = q{ static foreach(value; values1) mixin("bool " ~ value ~ " = false;"); }; enum qqq = [Key.First, Key.Last]; mixin(decl!qqq); } I don't