Chromium Code Reviews| Index: util/numeric/checked_range.h |
| diff --git a/util/numeric/checked_range.h b/util/numeric/checked_range.h |
| index e1a2abf8195716f7554c265341e7eeea9a215cae..d2d77eb63bfaf3d0257cd354d2473bfc6945c065 100644 |
| --- a/util/numeric/checked_range.h |
| +++ b/util/numeric/checked_range.h |
| @@ -104,11 +104,27 @@ class CheckedRange { |
| return that.base() >= base() && that.end() <= end(); |
| } |
| + //! \brief Returns whether the range overlaps another range. |
| + //! |
| + //! \param[in] that The (possibly) overlapping range. |
| + //! |
| + //! \return `true` if `this` range, the first range, overlaps \a that, |
| + //! the provided range. `false` otherwise. |
| + //! |
| + //! Ranges are considered to be open-closed [base, end) for this test. |
|
Mark Mentovai
2015/10/01 17:38:58
Isn’t that closed-open?
scottmg
2015/10/01 18:10:02
Oops, done.
|
| + //! |
| + //! This method must only be called if IsValid() would return `true` for both |
| + //! CheckedRange objects involved. |
| + bool OverlapsRange(const CheckedRange<ValueType, SizeType>& that) const { |
| + DCHECK(IsValid()); |
| + DCHECK(that.IsValid()); |
| + |
| + return base() < that.end() && that.base() < end(); |
| + } |
| + |
| private: |
| ValueType base_; |
| SizeType size_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(CheckedRange); |
| }; |
| } // namespace crashpad |