Bug 1354090: P2. Add operator+(val). r?gerald
Such that:
[x, y] + a = [x+a, y+a]
MozReview-Commit-ID: HlyI9KmVtTg
--- a/dom/media/Intervals.h
+++ b/dom/media/Intervals.h
@@ -96,24 +96,34 @@ public:
// Basic interval arithmetic operator definition.
SelfType operator+ (const SelfType& aOther) const
{
return SelfType(mStart + aOther.mStart,
mEnd + aOther.mEnd,
mFuzz + aOther.mFuzz);
}
+ SelfType operator+ (const T& aVal) const
+ {
+ return SelfType(mStart + aVal, mEnd + aVal, mFuzz);
+ }
+
// Basic interval arithmetic operator definition.
SelfType operator- (const SelfType& aOther) const
{
return SelfType(mStart - aOther.mEnd,
mEnd - aOther.mStart,
mFuzz + aOther.mFuzz);
}
+ SelfType operator- (const T& aVal) const
+ {
+ return SelfType(mStart - aVal, mEnd - aVal, mFuzz);
+ }
+
bool operator== (const SelfType& aOther) const
{
return mStart == aOther.mStart && mEnd == aOther.mEnd;
}
bool operator!= (const SelfType& aOther) const
{
return !(*this == aOther);