Question about eponymous template trick

Uranuz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 3 06:07:54 PST 2014


I have an example of code like this:

template Node(String)
{
	struct Node {}
	struct Name {}
	struct Attr {}
	
}

void main()
{
	alias MyNode = Node!(string).Node;
	alias MyName = Node!(string).Name;
	alias MyAttr = Node!(string).Attr;
	
}

This code fails during compilation with message:

Compilation output:

/d228/f410.d(12): Error: no property 'Node' for type 
'Node!string' /d228/f410.d(12): Error: no property 'Node' for 
type 'Node!string' /d228/f410.d(13): Error: no property 'Name' 
for type 'Node!string' /d228/f410.d(13): Error: no property 
'Name' for type 'Node!string' /d228/f410.d(14): Error: no 
property 'Attr' for type 'Node!string' /d228/f410.d(14): Error: 
no property 'Attr' for type 'Node!string'

So question is: is this intended behaviour and I'm missing 
something about eponymous templates? Or is it a bug in compiler?


More information about the Digitalmars-d-learn mailing list