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

Unified Diff: webrtc/base/array_view.h

Issue 1418423010: Pass audio to AudioEncoder::Encode() in an ArrayView (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: disconvert to bool Created 5 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') | webrtc/base/array_view_unittest.cc » ('J')
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 019bd8b6c6b8f37f348f3d8a4d87f742f9602eba..02676f17d187cbcbbdbba41f3612c5b5ba72e4b4 100644
--- a/webrtc/base/array_view.h
+++ b/webrtc/base/array_view.h
@@ -61,6 +61,7 @@ class ArrayView final {
// is const, because the ArrayView doesn't own the array. (To prevent
// mutation, use ArrayView<const T>.)
size_t size() const { return size_; }
+ bool empty() const { return size_ == 0; }
T* data() const { return data_; }
T& operator[](size_t idx) const {
RTC_DCHECK_LT(idx, size_);
@@ -72,6 +73,15 @@ class ArrayView final {
const T* cbegin() const { return data_; }
const T* cend() const { return data_ + size_; }
+ // Comparing two ArrayViews compares their (pointer,size) pairs; it does
+ // *not* dereference the pointers.
+ friend bool operator==(const ArrayView& a, const ArrayView& b) {
+ return a.data_ == b.data_ && a.size_ == b.size_;
+ }
+ friend bool operator!=(const ArrayView& a, const ArrayView& b) {
+ return !(a == b);
+ }
+
private:
// Invariant: !data_ iff size_ == 0.
void CheckInvariant() const { RTC_DCHECK_EQ(!data_, size_ == 0); }
« no previous file with comments | « no previous file | webrtc/base/array_view_unittest.cc » ('j') | webrtc/base/array_view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698