UDA: getAttributes does not play well with topleof
Jacob Carlborg
doob at me.com
Mon Dec 17 06:10:38 PST 2012
On 2012-12-17 12:55, d coder wrote:
> template Tuple(T...) {
> alias T Tuple;
> }
>
> enum Bar;
> class Foo {
> @Bar int a;
> int b;
> }
>
> void main() {
> Foo foo = new Foo;
> foreach(ref l; foo.tupleof) {
> alias Tuple!(__traits(getAttributes, l)) tp;
> pragma(msg, tp);// prints nothing
> }
> alias Tuple!(__traits(getAttributes, foo.a)) tp;
> pragma(msg, tp); // prints (Bar)
> }
>
Try something like this:
foreach (i, dummy, foo.tupleof)
{
alias Tuple!(__traits(getAttributes, foo.tupleof[i])) tp;
pragma(msg, tp);
}
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list