hello guys,
i would like to have properties with /= *= += -= operators. My code:

struct Point {
  float x=0,y=0;

  this(float _x, float _y) {
    x=_x;
    y=_y;
  }

  //opassign for +

  //opopassign for +=
  void opOpAssign(string op=="+")(in Point p) {
    x+=p.x;
    y+=p.y;
  }
}

class A {
  public:
    Point location() const @property {
      return m_location;
    }

    void location(in Point newlocation) @property {
      m_location=newlocation;
    }

  private:
    Point m_location;
}

void main() {
  auto a= new A;
  a.location=a.location+Point(1,1); //DOES WORK
  a.location+=Point(1,1); //DOESN'T WORK
}



The problem is that this code is not working. The getter and the opOpAssign gets called, but the setter does not.
How can i do opOpAssign with properties??

Reply via email to