Added an operator[] to Buffer, to make reading data easier.
Review URL: https://codereview.webrtc.org/1745033002
Cr-Original-Commit-Position: refs/heads/master@{#11819}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: b9338ac62b9a8a64568a62ad9ae4f2f7c3f732ca
diff --git a/base/buffer.h b/base/buffer.h
index 0ef1e3b..6fe9185 100644
--- a/base/buffer.h
+++ b/base/buffer.h
@@ -124,6 +124,16 @@
bool operator!=(const Buffer& buf) const { return !(*this == buf); }
+ uint8_t& operator[](size_t index) {
+ RTC_DCHECK_LT(index, size_);
+ return data()[index];
+ }
+
+ uint8_t operator[](size_t index) const {
+ RTC_DCHECK_LT(index, size_);
+ return data()[index];
+ }
+
// The SetData functions replace the contents of the buffer. They accept the
// same input types as the constructors.
template <typename T, typename internal::ByteType<T>::t = 0>