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

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: 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
Index: webrtc/base/array_view.h
diff --git a/webrtc/base/array_view.h b/webrtc/base/array_view.h
index 019bd8b6c6b8f37f348f3d8a4d87f742f9602eba..85c814de2a6729190d55249d2b83cc2ae6805984 100644
--- a/webrtc/base/array_view.h
+++ b/webrtc/base/array_view.h
@@ -72,6 +72,18 @@ class ArrayView final {
const T* cbegin() const { return data_; }
const T* cend() const { return data_ + size_; }
+ // An ArrayView is false iff it's empty.
+ explicit operator bool() const { return size_ > 0; }
+
+ // 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/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698