UDA tuple flattening

Max Samukha maxsamukha at gmail.com
Tue Dec 18 10:02:14 PST 2012


On Tuesday, 18 December 2012 at 17:31:49 UTC, jerro wrote:
> 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(){}

Definitely a bug.


More information about the Digitalmars-d mailing list