On 2020-03-07 16:41:47 +0000, MoonlightSentinel said:
You can use an anonymous lambda to build the string in CTFE: ------------------------------------------ struct S { int a; bool b; } import std; enum string sql = { string s = "CREATE TABLE data("; static foreach(f; FieldNameTuple!S) { s ~= f ~ ","; } s ~= ");"; return s; } (); pragma(msg, sql); ------------------------------------------ This prints "CREATE TABLE data(a, b);"
You can get rid of the enum und the static and it will work too. -- Robert M. Münch http://www.saphirion.com smarter | better | faster