Add begin()/end() to CopyOnWriteBuffer.

This allows this type to meet the requirements of e.g.
std::ranges::range, which is necessary for it to work with the std::span
range constructor, or the "non-legacy" constructor for Chromium's
base::span.

Bug: chromium:364987728
Change-Id: I6cb2b9c6d849c97e304719140dcb967a9e2c254c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365780
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43251}
This commit is contained in:
Peter Kasting 2024-10-15 13:05:10 -07:00 committed by WebRTC LUCI CQ
parent e8d27c7092
commit f29fb25555

View File

@ -144,6 +144,9 @@ class RTC_EXPORT CopyOnWriteBuffer {
return buffer_ ? buffer_->capacity() - offset_ : 0; return buffer_ ? buffer_->capacity() - offset_ : 0;
} }
const uint8_t* begin() const { return data(); }
const uint8_t* end() const { return data() + size_; }
CopyOnWriteBuffer& operator=(const CopyOnWriteBuffer& buf) { CopyOnWriteBuffer& operator=(const CopyOnWriteBuffer& buf) {
RTC_DCHECK(IsConsistent()); RTC_DCHECK(IsConsistent());
RTC_DCHECK(buf.IsConsistent()); RTC_DCHECK(buf.IsConsistent());