mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
libtemporal: correct the definition of std::numeric_limits<Beats>::max(). Comment in code contains details.
This commit is contained in:
parent
cb66ae496c
commit
1af74f7398
1 changed files with 14 additions and 4 deletions
|
|
@ -324,12 +324,22 @@ namespace std {
|
|||
return Temporal::Beats(std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::min());
|
||||
}
|
||||
|
||||
/* We don't define min() since this has different behaviour for integral and floating point types,
|
||||
but Beats is used as both. Better to avoid providing a min at all
|
||||
than a confusing one. */
|
||||
/* We don't define min() since this has different behaviour for
|
||||
integral and floating point types, but Beats is used as both
|
||||
an integral and "fractional" value, so the semantics of
|
||||
min() would be unclear.
|
||||
|
||||
Better to avoid providing a min at all than a confusing one.
|
||||
*/
|
||||
|
||||
/* We must make the number of beats be 1 less than INT32_MAX,
|
||||
* because otherwise adding the PPQN-1 ticks would cause
|
||||
* overflow (the value would be INT32_MAX+((PPQN-1)/PPQN) which
|
||||
* exceeds INT32_MAX.
|
||||
*/
|
||||
|
||||
static Temporal::Beats max() {
|
||||
return Temporal::Beats(std::numeric_limits<int32_t>::max(), Temporal::Beats::PPQN-1);
|
||||
return Temporal::Beats(std::numeric_limits<int32_t>::max() - 1, Temporal::Beats::PPQN - 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue