Re: Why can't I have overloading and generics?

2012-03-10 Thread sclytrack
On 03/10/2012 04:32 AM, Caligo wrote: struct B { } struct C { } struct D { } struct A { ref A foo(B item) { /* do something special. */ return this; } ref A foo(T)(T item) if(is(T == C) || is(T == D)) { /* nothing special, do

Re: Why can't I have overloading and generics?

2012-03-10 Thread David
You can strip ref A foo(T)(T item) if (is(T==B)) { down to: ref A foo(T : B)(T item) // or to match your example ref A foo(T == B)(T item)

Re: Why can't I have overloading and generics?

2012-03-10 Thread so
On Saturday, 10 March 2012 at 03:32:44 UTC, Caligo wrote: struct B { } struct C { } struct D { } struct A { ref A foo(B item) { /* do something special. */ return this; } ref A foo(T)(T item) if(is(T == C) || is(T == D)) { /* nothing

Re: Why can't I have overloading and generics?

2012-03-10 Thread Jesse Phillips
Templates not overriding non-template functions is a bug http://d.puremagic.com/issues/show_bug.cgi?id=1528

Why can't I have overloading and generics?

2012-03-09 Thread Caligo
struct B { } struct C { } struct D { } struct A { ref A foo(B item) { /* do something special. */ return this; } ref A foo(T)(T item) if(is(T == C) || is(T == D)) { /* nothing special, do the same for C and D. */ return this;

Re: Why can't I have overloading and generics?

2012-03-09 Thread Jonathan M Davis
On Friday, March 09, 2012 21:32:35 Caligo wrote: struct B { } struct C { } struct D { } struct A { ref A foo(B item) { /* do something special. */ return this; } ref A foo(T)(T item) if(is(T == C) || is(T == D)) { /* nothing