mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-25 22:29:07 +00:00
Bug 1276573 - Add a new constructor for Range<T>. r=Waldo
These new constructor accepts two RangedPtr<T> arguments. MozReview-Commit-ID: 8a3bYserLMr --HG-- extra : rebase_source : 216de17b7a51783fe48d604b432d4dc7df6ad6eb
This commit is contained in:
parent
b7270d91cb
commit
c329f132b7
@ -26,6 +26,14 @@ public:
|
||||
: mStart(aPtr, aPtr, aPtr + aLength),
|
||||
mEnd(aPtr + aLength, aPtr, aPtr + aLength)
|
||||
{}
|
||||
Range(const RangedPtr<T>& aStart, const RangedPtr<T>& aEnd)
|
||||
: mStart(aStart.get(), aStart.get(), aEnd.get()),
|
||||
mEnd(aEnd.get(), aStart.get(), aEnd.get())
|
||||
{
|
||||
// Only accept two RangedPtrs within the same range.
|
||||
aStart.checkIdenticalRange(aEnd);
|
||||
MOZ_ASSERT(aStart <= aEnd);
|
||||
}
|
||||
|
||||
RangedPtr<T> start() const { return mStart; }
|
||||
RangedPtr<T> end() const { return mEnd; }
|
||||
|
@ -117,6 +117,12 @@ public:
|
||||
|
||||
explicit operator bool() const { return mPtr != nullptr; }
|
||||
|
||||
void checkIdenticalRange(const RangedPtr<T>& aOther) const
|
||||
{
|
||||
MOZ_ASSERT(mRangeStart == aOther.mRangeStart);
|
||||
MOZ_ASSERT(mRangeEnd == aOther.mRangeEnd);
|
||||
}
|
||||
|
||||
/*
|
||||
* You can only assign one RangedPtr into another if the two pointers have
|
||||
* the same valid range:
|
||||
@ -129,8 +135,7 @@ public:
|
||||
*/
|
||||
RangedPtr<T>& operator=(const RangedPtr<T>& aOther)
|
||||
{
|
||||
MOZ_ASSERT(mRangeStart == aOther.mRangeStart);
|
||||
MOZ_ASSERT(mRangeEnd == aOther.mRangeEnd);
|
||||
checkIdenticalRange(aOther);
|
||||
mPtr = aOther.mPtr;
|
||||
checkSanity();
|
||||
return *this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user