UDA: getAttributes does not play well with topleof
d coder
dlang.coder at gmail.com
Mon Dec 17 08:40:22 PST 2012
On Mon, Dec 17, 2012 at 9:56 PM, Walter Bright
<newshound2 at digitalmars.com>wrote:
> On 12/17/2012 3:55 AM, d coder wrote:
>
>> So my question is: Is this a bug in DMD, or am I doing something plainly
>> wrong?
>>
>
> You're doing something wrong. Consider:
>
> @Bar int i = 3;
> int x = i;
>
> The UDA does not get transferred to x. This is why your loop:
>
> foreach(ref l; foo.tupleof)
>
> does not transfer the UDAs to l.
>
>
But Walter, even the code below does not work.
Error: first argument is not a symbol
tuple(false)
template Tuple(T...) {
alias T Tuple;
}
enum Bar;
class Foo {
@Bar int a;
}
void main()
{
Foo foo = new Foo;
alias Tuple!(__traits(getAttributes, foo.tupleof[0])) tp;
pragma(msg, tp);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121217/1973e51d/attachment-0001.html>
More information about the Digitalmars-d
mailing list