13
0

Temporal: correctly construct return timepos_t for * and /

This commit is contained in:
Paul Davis 2020-08-04 17:41:11 -06:00
parent e89d727939
commit 8ec81c2308
2 changed files with 6 additions and 2 deletions

View File

@ -198,6 +198,10 @@ class timepos_t : public int62_t {
private:
int64_t v;
/* special private constructor for use when constructing timepos_t as a
return value using arithmetic ops
*/
explicit timepos_t (bool b, int64_t v) : int62_t (b, v) {}
static timepos_t _max_timepos;

View File

@ -264,14 +264,14 @@ timepos_t::operator/(ratio_t const & n) const
/* note: v / (N/D) = (v * D) / N */
return timepos_t (int_div_round (val() * n.denominator(), n.numerator()));
return timepos_t (is_beats(), int_div_round (val() * n.denominator(), n.numerator()));
}
timepos_t
timepos_t::operator*(ratio_t const & n) const
{
assert (n >= 0); /* do not allow a position to become negative via multiplication */
return timepos_t (int_div_round (val() * n.numerator(), n.denominator()));
return timepos_t (is_beats(), int_div_round (val() * n.numerator(), n.denominator()));
}
timepos_t &