UDA strange behavior
Jacob Carlborg
doob at me.com
Sun Jun 9 10:34:36 PDT 2013
On 2013-06-09 11:15, Temtaime wrote:
> @(3) int a;
> enum tp = __traits(getAttributes, a);
>
> enum b = tp[0];
> writeln(b);
>
> Compiler doesn't accept enum b = tp[0] and says to me:
> Error: variable _tp_field_0 cannot be read at compile time
>
> Why? And writeln(tp[0]) works as expected.
__traits(getAttributes) returns a tuple. Try using an alias instead,
something like:
import std.typetuple
alias tp = TypeTuple!(__traits(getAttributes, a));
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list