Template method and overloading
Bill Baxter
dnewsgroup at billbaxter.com
Tue May 29 12:39:38 PDT 2007
gerleim wrote:
> Why
> "template test.A.Foo(T) conflicts with test.A.Foo(T) at ..."
> ?
>
> public class A
> {
> public void Foo(T)(T p1)
> {
> }
>
> public void Foo(T)(T p1, bool b)
> {
> }
> }
>
> The two methods has different signatures.
> I'm not really familiar with c++ templates, but c#/.net can handle this.
>
> What's the reason behind this, and will the behaviour change?
>
> Thanks,
> gerleim
Yeh that's not allowed. I presume the reason was it was easier to
implement this way.
The workaround is to give them different *template* parameter lists.
Something like:
public void Foo(T)(T p1)
{
}
public void Foo(T,dummy=float)(T p1, bool b)
{
}
It's silly that you have to do that, but since that workaround is
available, I don't think Walter considers fixing it a very high priority.
--bb
More information about the Digitalmars-d-learn
mailing list