diff options
Diffstat (limited to 'third_party/base/span.h')
-rw-r--r-- | third_party/base/span.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/third_party/base/span.h b/third_party/base/span.h index d8d8f29e7c..034c6a35e7 100644 --- a/third_party/base/span.h +++ b/third_party/base/span.h @@ -13,6 +13,7 @@ #include <type_traits> #include <utility> +#include "core/fxcrt/unowned_ptr.h" #include "third_party/base/logging.h" namespace pdfium { @@ -224,14 +225,14 @@ class span { const span last(size_t count) const { CHECK(count <= size_); - return span(data_ + (size_ - count), count); + return span(data_.Get() + (size_ - count), count); } const span subspan(size_t pos, size_t count = -1) const { const auto npos = static_cast<size_t>(-1); CHECK(pos <= size_); CHECK(count == npos || count <= size_ - pos); - return span(data_ + pos, count == npos ? size_ - pos : count); + return span(data_.Get() + pos, count == npos ? size_ - pos : count); } // [span.obs], span observers @@ -241,13 +242,13 @@ class span { // [span.elem], span element access const T& operator[](size_t index) const noexcept { CHECK(index < size_); - return data_[index]; + return data_.Get()[index]; } - constexpr T* data() const noexcept { return data_; } + constexpr T* data() const noexcept { return data_.Get(); } // [span.iter], span iterator support - constexpr iterator begin() const noexcept { return data_; } - constexpr iterator end() const noexcept { return data_ + size_; } + constexpr iterator begin() const noexcept { return data_.Get(); } + constexpr iterator end() const noexcept { return data_.Get() + size_; } constexpr const_iterator cbegin() const noexcept { return begin(); } constexpr const_iterator cend() const noexcept { return end(); } @@ -267,7 +268,7 @@ class span { } private: - T* data_; + UnownedPtr<T> data_; size_t size_; }; |