provide unary minus to flip a TimeVar around origin
This commit is contained in:
parent
d30515c37e
commit
3cf9974211
2 changed files with 8 additions and 0 deletions
|
|
@ -138,6 +138,9 @@ namespace time {
|
|||
|
||||
// Supporting multiplication with integral factor
|
||||
TimeVar& operator*= (int fact) { t_ *= fact; return *this; }
|
||||
|
||||
// Supporting flip sign
|
||||
TimeVar operator- () const { return TimeVar(*this)*=-1; }
|
||||
|
||||
// baseclass TimeValue is already totally_ordered
|
||||
};
|
||||
|
|
|
|||
|
|
@ -144,6 +144,11 @@ namespace test{
|
|||
gavl_time_t raw (var);
|
||||
CHECK (raw == org);
|
||||
CHECK (raw > org - two);
|
||||
|
||||
// unary minus will flip around origin
|
||||
CHECK (zero == -var + var);
|
||||
CHECK (zero != -var);
|
||||
CHECK (var == org); // unaltered
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue