Skip to content

Commit

Permalink
[jumbo] Add begin()/end() to Slice.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pkasting committed Aug 8, 2024
1 parent 068d5ee commit 2cc36eb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/leveldb/slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class LEVELDB_EXPORT Slice {
// Return true iff the length of the referenced data is zero
bool empty() const { return size_ == 0; }

const char* begin() const { return data(); }
const char* end() const { return data() + size(); }

// Return the ith byte in the referenced data.
// REQUIRES: n < size()
char operator[](size_t n) const {
Expand Down

0 comments on commit 2cc36eb

Please sign in to comment.