Re: Compound assignment operators

2010-08-26 Thread Jonathan M Davis
On Wednesday 25 August 2010 23:49:27 Yao G. wrote: > On Thu, 26 Aug 2010 01:46:02 -0500, Jonathan M Davis > > wrote: > > Look at http://www.digitalmars.com/d/2.0/operatoroverloading.html (or > > even > > better, TDPL). The correct function would be opOpAssign. I believe that > > the > > syntax fo

Re: Compound assignment operators

2010-08-25 Thread Yao G.
On Thu, 26 Aug 2010 01:46:02 -0500, Jonathan M Davis wrote: Look at http://www.digitalmars.com/d/2.0/operatoroverloading.html (or even better, TDPL). The correct function would be opOpAssign. I believe that the syntax for += would be opOpAssign!("+")(args) { } - Jonathan M Davis Ha ha

Re: Compound assignment operators

2010-08-25 Thread Jonathan M Davis
On Wednesday 25 August 2010 22:31:38 Yao G. wrote: > Sorry, I sent the message prematurely :( Anyway, here's complete: > > Is there a way to make compound assignment operators (-=, +=, *= and > friends) work with D's operator overload regime? I can't ma

Re: Compound assignment operators

2010-08-25 Thread bearophile
Yao G.: > Is there a way to make this work? Even changing the operator string in > opBinary to "-" doesn't do nothing. Or those kind of operators can't be > overloaded? Try opOpAssign. Bye, bearophile

Re: Compound assignment operators

2010-08-25 Thread Yao G.
Sorry, I sent the message prematurely :( Anyway, here's complete: Is there a way to make compound assignment operators (-=, +=, *= and friends) work with D's operator overload regime? I can't make them work. struct Foo { this( int bar ) { bar = bar; } Foo

Compound assignment operators

2010-08-25 Thread Yao G.
Is there a way to make compound assignment operators (-=, +=, *= and friends) work with D's operator overload regime? I can't make them work. struct Foo { this( int foo ) Foo opBinary(string op)( in typeof(this) rhv ) if( op == "-=" ) {