Fix range "arithmetic"
Subtracting anything from an empty range should return an empty range, not an assert() failure
This commit is contained in:
parent
9ca0ce4b7f
commit
e4f61de52f
@ -137,6 +137,7 @@ struct /*LIBEVORAL_API*/ Range {
|
||||
Range (T f, T t) : from (f), to (t) {}
|
||||
T from; ///< start of the range
|
||||
T to; ///< end of the range (inclusive: to lies inside the range)
|
||||
bool empty() const { return from == to; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -215,7 +216,7 @@ RangeList<T> subtract (Range<T> range, RangeList<T> sub)
|
||||
RangeList<T> result;
|
||||
result.add (range);
|
||||
|
||||
if (sub.empty ()) {
|
||||
if (sub.empty () || range.empty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user