Template Usage with Eponymous Trick

Paul Backus snarwin at gmail.com
Sun Feb 2 23:48:45 UTC 2020


On Sunday, 2 February 2020 at 23:39:10 UTC, ShadoLight wrote:
> But, my question was if this was avoidable if braces were not 
> optional. Paul's answer was that non-optional braces will not 
> make...
>     alias a = S!(int);
> ... non-ambiguous, but I still don't get that based on the 
> above results.

The results you've shown are based on the currently-implemented 
behavior, which is indeed unambiguous: S!(int) always refers to 
the eponymous struct, not the template instance that contains it. 
This is true whether or not you use braces.

If the behavior were changed as you have previously proposed, so 
that `S!(int)` could refer *either* to the eponymous struct *or* 
the template instance, then the alias declaration would become 
ambiguous. Again, this would be true whether or not you used 
braces.


More information about the Digitalmars-d-learn mailing list