xxxxxxxxxx
--- app.d
import foo_module;
import std.stdio, std.traits;
void main()
{
Foo foo;
static foreach(member; __traits(allMembers, Foo))
{
// there is no simple way to distinct Type and private field i. You can use FieldNameTuple to filter fields out. But if the aggregate contains enum(s) you failed again because .tupleof does not contain enums.
enum isItType = isTypeTuple!(__traits(getMember, Foo, member)); // you cannot get access to i to check if it is a type
enum protectionLevel = __traits(getProtection, __traits(getMember, Foo, member)); // you cannot get protection for Type
pragma(msg, "is it type: ", isItType, " protection level: ", protectionLevel);
}
}
--- foo_module.d
struct Foo
{
alias Type = ushort;
private:
int i;
}