Template method and overloading

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue May 29 13:55:03 PDT 2007


"gerleim" <elf_qt at _deletethisifyouarenotaspammer_yahoo.com> wrote in message 
news:f3hvvt$2q18$1 at digitalmars.com...
> Oh, I see, thanks. Didn't know that template parameter lists have to 
> differ.
> (Is that documented?)
>

It's because templated functions are really just syntactic sugar.  So:

void foo(T)(int x){}
void foo(T)(int x, float y){}

Is really seen by the compiler as:

template foo(T) { void foo(int x){} }
template foo(T) { void foo(int x, float y){} }

Now it looks obvious that there should be an error, because it's the 
templates that are at top-level, not the functions. 




More information about the Digitalmars-d-learn mailing list