From 42879f6ea60b703132549f948b8914b91fe14b09 Mon Sep 17 00:00:00 2001 From: pkasting Date: Mon, 19 Aug 2024 21:12:35 -0700 Subject: [PATCH] [jumbo] Add begin()/end() to DetachedBuffer. (#8370) 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: none Co-authored-by: Derek Bailey --- include/flatbuffers/detached_buffer.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/flatbuffers/detached_buffer.h b/include/flatbuffers/detached_buffer.h index 5e900baeb..36d3f6d6d 100644 --- a/include/flatbuffers/detached_buffer.h +++ b/include/flatbuffers/detached_buffer.h @@ -80,6 +80,11 @@ class DetachedBuffer { size_t size() const { return size_; } + uint8_t *begin() { return data(); } + const uint8_t *begin() const { return data(); } + uint8_t *end() { return data() + size(); } + const uint8_t *end() const { return data() + size(); } + // These may change access mode, leave these at end of public section FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other)); FLATBUFFERS_DELETE_FUNC(