Skip to content

Commit 002dc75

Browse files
committed
bug fix unary minus on MPTime
1 parent a5c9b68 commit 002dc75

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

include/maxplus/algebra/mptype.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MPTime {
6565

6666
explicit operator CDouble() const { return myVal; }
6767
explicit operator MPString() const { return timeToString(*this); }
68-
MPTime &operator-();
68+
MPTime operator-();
6969
MPTime &operator+=(MPTime a);
7070
MPTime &operator-=(MPTime a);
7171
bool operator==(MPTime a) const;
@@ -153,10 +153,9 @@ inline MPTime operator-(MPTime a, CDouble b) { return MPTime(a) - MPTime(b); }
153153

154154
inline MPTime operator-(CDouble a, MPTime b) { return MPTime(a) - MPTime(b); }
155155

156-
inline MPTime &MPTime::operator-() {
156+
inline MPTime MPTime::operator-() {
157157
assert(!this->isMinusInfinity());
158-
myVal = -myVal;
159-
return *this;
158+
return MPTime(-myVal);
160159
}
161160

162161
inline MPTime operator*(MPTime a, MPTime b) {

0 commit comments

Comments
 (0)