Skip to content
Snippets Groups Projects
Commit 38ced92d authored by Axel Naumann's avatar Axel Naumann
Browse files

Add unary -op for UDLs to work nicely.

parent cfdb37b7
Branches
Tags
No related merge requests found
...@@ -33,6 +33,8 @@ protected: ...@@ -33,6 +33,8 @@ protected:
CoordSysBase(double val): fVal(val) {} CoordSysBase(double val): fVal(val) {}
DERIVED &ToDerived() { return static_cast<DERIVED &>(*this); } DERIVED &ToDerived() { return static_cast<DERIVED &>(*this); }
DERIVED operator-() { return DERIVED(-fVal); }
friend DERIVED operator+(DERIVED lhs, DERIVED rhs) { return DERIVED{lhs.fVal + rhs.fVal}; } friend DERIVED operator+(DERIVED lhs, DERIVED rhs) { return DERIVED{lhs.fVal + rhs.fVal}; }
friend DERIVED operator-(DERIVED lhs, DERIVED rhs) { return DERIVED{lhs.fVal - rhs.fVal}; } friend DERIVED operator-(DERIVED lhs, DERIVED rhs) { return DERIVED{lhs.fVal - rhs.fVal}; }
friend double operator/(DERIVED lhs, DERIVED rhs) { return lhs.fVal / rhs.fVal; } friend double operator/(DERIVED lhs, DERIVED rhs) { return lhs.fVal / rhs.fVal; }
...@@ -124,6 +126,11 @@ public: ...@@ -124,6 +126,11 @@ public:
return TPadCoord{lhs.fNormal - rhs.fNormal, lhs.fPixel - rhs.fPixel, lhs.fUser - rhs.fUser}; return TPadCoord{lhs.fNormal - rhs.fNormal, lhs.fPixel - rhs.fPixel, lhs.fUser - rhs.fUser};
} }
/// Unary -.
TPadCoord operator-() {
return TPadCoord(-fNormal, -fPixel, -fUser);
}
/// Add a `TPadCoord`. /// Add a `TPadCoord`.
TPadCoord &operator+=(const TPadCoord &rhs) TPadCoord &operator+=(const TPadCoord &rhs)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment