Question about eponymous template trick
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 3 08:46:20 PST 2014
On 11/3/14 9:07 AM, Uranuz wrote:
> 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?
This is troubling. So you can never access struct Name inside there?
This USED to work IIRC, but then again, the eponymous trick only used to
work if there was only one member in the template.
-Steve
More information about the Digitalmars-d-learn
mailing list