UDA tuple flattening

jerro a at a.com
Tue Dec 18 09:31:48 PST 2012


I noticed that this doesn't work with the latest DMD from github:

import std.typetuple;

struct Foo{}
struct Bar{}

alias TypeTuple!(Foo, Bar) FooBar;

@FooBar
void foo(){}

pragma(msg, __traits(getAttributes, foo));

When trying to compile this, the compiler prints:

a.d(6): Error: cannot form tuple of tuples
tuple(((Foo, Bar)))

Would it not make sense for the tuples of attributes to be 
automatically flattened, as tuples are in other places? This 
would also allow one to do stuff like this, which I think could 
be very useful:

static if(something)
     alias TypeTuple!(A, B, C) fooAttributes;
else
     alias TypeTuple!(C, D) fooAttributes;

@fooAttributes
void foo(){}



More information about the Digitalmars-d mailing list