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

Unified Diff: webrtc/base/array_view.h

Issue 2502383004: Introduce ArrayView::subview function (Closed)
Patch Set: 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..1ff46543170093c50ea8a9a0db8030d6910d53bc 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 nullptr;
kwiberg-webrtc 2016/11/18 01:57:36 It's probably good to add a comment saying that nu
danilchap 2016/11/18 09:05:33 Done. (wasn't sure ArrayView() or nullptr give bet
+ 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