Added an operator[] to Buffer, to make reading data easier.

Review URL: https://codereview.webrtc.org/1745033002

Cr-Commit-Position: refs/heads/master@{#11819}
This commit is contained in:
ossu
2016-02-29 09:36:37 -08:00
committed by Commit bot
parent 012f8c0e73
commit b9338ac62b
2 changed files with 49 additions and 0 deletions

View File

@ -124,6 +124,16 @@ class Buffer {
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>