provide unary minus to flip a TimeVar around origin

This commit is contained in:
Fischlurch 2011-01-08 19:11:42 +01:00
parent d30515c37e
commit 3cf9974211
2 changed files with 8 additions and 0 deletions

View file

@ -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
};

View file

@ -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
}