alias and UDAs

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 11 03:39:03 PDT 2017


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é


More information about the Digitalmars-d-learn mailing list