December 18, 2012 UDA tuple flattening | ||||
---|---|---|---|---|
| ||||
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(){} |
December 18, 2012 Re: UDA tuple flattening | ||||
---|---|---|---|---|
| ||||
Posted in reply to jerro | 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.
|
Copyright © 1999-2021 by the D Language Foundation