Accessing UDA of private field

Jacob Carlborg doob at me.com
Sun Jan 6 12:58:41 PST 2013


On 2013-01-06 18:29, Philippe Sigaud wrote:

> 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
> }

Good thinking. It's not pretty but it works. Thanks.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list