Hi,
i am trying to generate members for all types in a variadic class
template like this:
import std.stdio;
class Component(Children...) {
/// results eg. in public Component1 fComponent1;
static string createMembers() {
string res = "";
foreach (child; Children) {
res ~= "public " ~ child.stringof ~ " f" ~ child.stringof ~ ";\n";
}
return res;
}
mixin(createMembers());
}
class Component1 : Component!() {
}
class Component2 : Component!(Component1) {
}
int main(string[] args) {
writeln([ __traits(allMembers, Component2) ]);
return 0;
}
as you can see, Component2 now has a member called fComponent1.
My question is, is it possible to generate this with some mapping
algorithm, instead of writing this loop by hand?
regards
christian koestlin