Alias vs templates

Jean-Louis Leroy jl at leroy.nyc
Wed Feb 21 20:32:40 UTC 2018


On Wednesday, 21 February 2018 at 20:27:29 UTC, Steven 
Schveighoffer wrote:
> On 2/21/18 1:46 PM, Jean-Louis Leroy wrote:
>> [...]
>
> I think because one is a function, which is allowed to be 
> overloaded, the other is a symbol.
>
> But clearly, there are some liberties taken when you are 
> overloading function templates, as overloading them works just 
> fine. I think this may have been a patch at some point (you 
> didn't use to be able to overload template functions with 
> normal functions).
>
> It seems like a reasonable request that this code should work.
>

I just discovered that this works:

int baz(T)();

struct Baz {
   static int baz(T)(T x) { return x; }
}

alias baz(T) = Baz.baz!T;


More information about the Digitalmars-d-learn mailing list