aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kasting <pkasting@chromium.org>2024-07-25 09:39:54 -0700
committerPeter Kasting <pkasting@chromium.org>2024-08-08 11:22:23 -0700
commit2cc36eb56668306c64fc611fb7ad63ecf0b20379 (patch)
tree546ab82922ee678262acecf83c51ee4408ff980b
parent068d5ee1a3ac40dabd00d211d5013af44be55bea (diff)
downloadleveldb-2cc36eb56668306c64fc611fb7ad63ecf0b20379.tar.gz
leveldb-2cc36eb56668306c64fc611fb7ad63ecf0b20379.zip
[jumbo] Add begin()/end() to Slice.
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
-rw-r--r--include/leveldb/slice.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h
index 37cb821..e97223a 100644
--- a/include/leveldb/slice.h
+++ b/include/leveldb/slice.h
@@ -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 {