Eponymous template with full template syntax
Jonathan M Davis
jmdavisProg at gmx.com
Mon Jul 1 11:50:36 PDT 2013
On Monday, July 01, 2013 11:15:04 Ali Çehreli wrote:
> I think main's second line used to work:
>
> template isSmall(T)
> {
> enum isSmall = (T.sizeof < 12345);
> }
>
> void main()
> {
> static assert(isSmall!int); // <-- the usual syntax works
>
> static assert(isSmall!int.isSmall); // <-- compilation ERROR
> }
>
> Error: template deneme.isSmall does not match any function template
> declaration. Candidates are:
> deneme.isSmall(T)
> Error: template deneme.isSmall(T) cannot deduce template function from
> argument types !()(bool)
>
> Am I imagining it? I don't have a problem with it. :) Was the change
> intentional?
I'm not aware of it ever having worked, but given that the whole point of
eponymous templates is that they be replaced with the symbol carrying their
name and _everything_ else in the template is hidden, I would think that what
you're seeing is correct behavior.
isSmall!int is replaced with the isSmall within isSmall!int, and
isSmall.isSmall makes no sense, so if that was allowed before, I'd definitely
argue that disallowing it was a bug fix.
- Jonathan m Davis
More information about the Digitalmars-d-learn
mailing list