Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: webrtc/base/array_view.h

Issue 2502383004: Introduce ArrayView::subview function (Closed)
Patch Set: nullptr -> ArrayView() Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/array_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/array_view.h
diff --git a/webrtc/base/array_view.h b/webrtc/base/array_view.h
index 5c1ffe24897f5307687a7ed7d58c12ab66cee0c6..aa73ef72f604074b251e64f580c9fb3e30ae4bfb 100644
--- a/webrtc/base/array_view.h
+++ b/webrtc/base/array_view.h
@@ -120,6 +120,13 @@ class ArrayView final {
const T* cbegin() const { return data_; }
const T* cend() const { return data_ + size_; }
+ ArrayView subview(size_t offset, size_t size) const {
+ if (offset >= size_)
+ return ArrayView();
+ return ArrayView(data_ + offset, std::min(size, size_ - offset));
+ }
+ ArrayView subview(size_t offset) const { return subview(offset, size_); }
+
// Comparing two ArrayViews compares their (pointer,size) pairs; it does
// *not* dereference the pointers.
friend bool operator==(const ArrayView& a, const ArrayView& b) {
« no previous file with comments | « no previous file | webrtc/base/array_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698