Operators overloading in D2 again

2010-05-02 Thread Dan
Hi everyone, is there anyway to do this with operators overloading? : class Tester { double x = 0.0; double opBinary(string op:+)(double value) { return x+value; } Tester opBinary(string op:+)(Tester other) {

Re: Operators overloading in D2 again

2010-05-02 Thread Ali Çehreli
Dan wrote: Hi everyone, is there anyway to do this with operators overloading? : class Tester { double x = 0.0; double opBinary(string op:+)(double value) { return x+value; } Tester opBinary(string op:+)(Tester other) {

Re: Operators overloading in D2 again

2010-05-02 Thread Robert Clipsham
On 02/05/10 07:14, Dan wrote: Hi everyone, is there anyway to do this with operators overloading? : The following code does it: class Tester { double x = 0.0; T opBinary(string op:+, T)(T value) if(is(T : double)) { return x+value; }