Pass template parameter into q{} string

Andrey saasecondbox at yandex.ru
Mon Apr 1 17:32:29 UTC 2019


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 understand how to pass template parameter "values1" into 
q{} string to get this output:
> static foreach(value; [Key.First, Key.Last])
>     mixin("bool " ~ value ~ " = false;");
or
> static foreach(value; qqq)
>     mixin("bool " ~ value ~ " = false;");


More information about the Digitalmars-d-learn mailing list