alias overloaded function template
Lemonfiend via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 12 05:17:13 PST 2014
> The problem is not the alias. The error message is about using
> the same identifier for two different things:
>
>> C:\...\temp_0186F968.d(13,1): Error: declaration foo(T)(T t,
>> int i) is already defined.
I'm not sure what is giving you that particular error. Without
the alias it compiles and runs fine for me.
When I wrap them individually in the template statement, it gives:
---
src\app.d(24): Error: template app.foo cannot deduce function
from argument types !()(int), candidates are:
src\app.d(40): app.foo(T)
src\app.d(45): app.foo(T)
---
When I wrap them together, I can indeed alias it, thanks!
> What you seem to forget is that the declarations:
> ---------------------
> void foo(T)(T t) {}
> void foo(T)(T t, int i) {}
> ---------------------
> are actually a two **Eponymous template** with the same name:
> ---------------------
> template foo(T){
> void foo(T t) {}
> }
> template foo(T){
> void foo(T t, int i) {}
> }
> ---------------------
Yes I had forgotten, assuming I ever knew :)
More information about the Digitalmars-d-learn
mailing list