UDA: getAttributes does not play well with topleof
d coder
dlang.coder at gmail.com
Mon Dec 17 03:55:12 PST 2012
Greetings
I am trying out the new UDA functionality in the github dmd. I wanted to
find out what different fields of a class carry a particular attribute. So
I tried to look at the set of attributes on all the fields returned by
tupleof. Interestingly I got nothing. On the other hand, when I explicitly
specify a particular field in the object, the attribute is getting printed
nicely on my screen.
So my question is: Is this a bug in DMD, or am I doing something plainly
wrong?
If this is not a bug, I want to find out if there would be a way to find
what different fields of a class carry a given attribute?
Thanks and Regards
- Puneet
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)
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121217/058e3c67/attachment.html>
More information about the Digitalmars-d
mailing list