Compound assignment operators

Yao G. yao.gomez at spam.gmail.com
Wed Aug 25 22:25:57 PDT 2010


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 == "-=" )
>     {
>          _bar -= rhv._bar;
>          return this;
>     }
>
>     private int _bar;
> }
>
> void main()
> {
>     au

-- 
Yao G.


More information about the Digitalmars-d-learn mailing list