import std.stdio;
struct A {
int b;
void c();
string d;
};
void main() {
// The following foreach is unrolled in compile time
foreach(name; __traits(allMembers, A)) {
pragma(msg, name);
}
}
The allMembers
traits returns a tuple of string containing the names of the members of the given type. These strings are known at compile time.