Eponymous template with full template syntax

Maxim Fomin maxim at maxim-fomin.ru
Mon Jul 1 12:03:59 PDT 2013


On Monday, 1 July 2013 at 18:15:06 UTC, 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?
>
> Ali

I think that this probably worked as early as in the end of 2011 
but I can be wrong as don't remember exactly.

It seems that dmd recognizes isSmall!int.isSmall as potential 
UFCS property, converts isSmall!int to bool and tries to issue 
call isSmall(bool) and fails, because that template does not 
define any function.


More information about the Digitalmars-d-learn mailing list