Function aliasing problem

Steven Schveighoffer schveiguy at
Tue Apr 21 22:13:31 UTC 2020

On 4/21/20 5:24 PM, Jean-Louis Leroy wrote:

> I would like to combine them all, e.g.:
>      alias sst(T) = SS!T.f;
>      int d = sst(42); // <=> SS!int.f(42)
> But it fails like this:
>      aliasstaticfunction.d(23): Error: template 
> `aliasstaticfunction.sst` cannot deduce function from argument types 
> `!()(int)`, candidates are:
>      aliasstaticfunction.d(22):        `sst(T)`

Implicit *Function* Template Instantiation (IFTI) only works on 
functions, not types. You are asking the compiler to deduce the template 
parameter of the struct from its inner function being called.

This is similar to constructors on templated types. D just doesn't do 
that currently.

You need a forwarder.


More information about the Digitalmars-d-learn mailing list