> The problem is that to access a UDA attached to a field I need to pass a
> symbol to the __traits(getAttributes). With "tupleof" I can get the name,
> type and value of a field but I cannot get a symbol.
>
> __traits(getMember) can be used to get the symbol but that will only work
> for public fields.
>

You can use a string mixin:

class Foo
{
    int a;
    @(3) private int b;
}

void main()
{
    writeln(mixin("__traits(getAttributes, " ~ Foo.tupleof[1].stringof ~
")")); // -> 3
}

Reply via email to