Help with operators

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Help with operators

martin nilsen
My operator bindings just crash
friend Vec  operator+ (C Vec     &v,   Flt      r) {return Vec(v.x+r,
v.y+r, v.z+r);}

friend Vec  operator- (C Vec     &v,   Flt      r) {return Vec(v.x-r,
v.y-r, v.z-r);}
friend Vec  operator* (C Vec     &v,   Flt      r) {return Vec(v.x*r,
v.y*r, v.z*r);}
friend Vec  operator/ (C Vec     &v,   Flt      r) {return Vec(v.x/r,
v.y/r, v.z/r);}

friend Vec  operator+ (C Vec     &a, C Vec     &b) {return
Vec(a.x+b.x, a.y+b.y, a.z+b.z);}
friend Vec  operator- (C Vec     &a, C Vec     &b) {return
Vec(a.x-b.x, a.y-b.y, a.z-b.z);}
friend Vec  operator* (C Vec     &a, C Vec     &b) {return
Vec(a.x*b.x, a.y*b.y, a.z*b.z);}
friend Vec  operator/ (C Vec     &a, C Vec     &b) {return
Vec(a.x/b.x, a.y/b.y, a.z/b.z);}

The binding I've tried
.def(self + float())
.def(float() + self)
.def(self + Vec())
.def(self - float())
.def(float() - self)
.def(self - Vec())
.def(self * float())
.def(float() * self)
.def(self * Vec())
.def(self / float())
.def(float() / self)
.def(self / Vec())
.def(self == Vec())

and I can't do
.def(C Vec() &+C Vec() &)
and from what i can understand is because it isn't really taking
itself as a param

but there is also

          Vec& operator+=(  Flt      r) {x+=  r; y+=  r; z+=  r; return T;}
          Vec& operator-=(  Flt      r) {x-=  r; y-=  r; z-=  r; return T;}
          Vec& operator*=(  Flt      r) {x*=  r; y*=  r; z*=  r; return T;}
          Vec& operator/=(  Flt      r) {x/=  r; y/=  r; z/=  r; return T;}
          Vec& operator+=(C Vec     &v) {x+=v.x; y+=v.y; z+=v.z; return T;}
          Vec& operator-=(C Vec     &v) {x-=v.x; y-=v.y; z-=v.z; return T;}
          Vec& operator*=(C Vec     &v) {x*=v.x; y*=v.y; z*=v.z; return T;}
          Vec& operator/=(C Vec     &v) {x/=v.x; y/=v.y; z/=v.z; return T;}
          Vec& operator*=(C Matrix3 &m) {return mul(m);}
          Vec& operator/=(C Matrix3 &m) {return div(m);}
          Vec& operator*=(C Matrix  &m) {return mul(m);}
          Vec& operator/=(C Matrix  &m) {return div(m);}
          Bool operator==(C Vec     &v)C;
          Bool operator!=(C Vec     &v)C;

but from what I understand these can't be binded?

What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
luabind-user mailing list
[hidden email]