On Thursday, 11 May 2017 at 10:39:03 UTC, Andre Pany wrote:
Hi,
in this example, both asserts fails. Is my assumption right,
that UDA on alias have no effect? If yes, I would like to see a
compiler warning.
But anyway, I do not understand why the second assertion fails.
Are UDAs on arrays not allowed?
import std.traits: hasUDA;
enum Flattened;
struct Foo
{
int bar;
}
@Flattened alias FooList = Foo[];
struct Baz
{
FooList fooList1;
@Flattened FooList[] fooList2;
}
void main()
{
Baz baz;
static assert(hasUDA!(baz.fooList1, "Flattened")); // => false
static assert(hasUDA!(baz.fooList2, "Flattened")); // => false
}
Kind regards
André
It should've been
alias FooList = @Flattened Foo[];
which will generate a compile-time error (UDAs not allowed for
alias declarations).
And then:
static assert(hasUDA!(baz.fooList2, Flattened));
No quotes, since Flattened is an enum, not a string