aboutsummaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/ConstBuffer.hxx11
-rw-r--r--src/util/WritableBuffer.hxx11
2 files changed, 22 insertions, 0 deletions
diff --git a/src/util/ConstBuffer.hxx b/src/util/ConstBuffer.hxx
index 7f1fa5aa6..6754cb065 100644
--- a/src/util/ConstBuffer.hxx
+++ b/src/util/ConstBuffer.hxx
@@ -143,6 +143,17 @@ struct ConstBuffer {
constexpr const_iterator cend() const {
return data + size;
}
+
+#ifdef NDEBUG
+ constexpr
+#endif
+ const T &operator[](size_type i) const {
+#ifndef NDEBUG
+ assert(i < size);
+#endif
+
+ return data[i];
+ }
};
#endif
diff --git a/src/util/WritableBuffer.hxx b/src/util/WritableBuffer.hxx
index 64e6d0c62..d13f80867 100644
--- a/src/util/WritableBuffer.hxx
+++ b/src/util/WritableBuffer.hxx
@@ -145,6 +145,17 @@ struct WritableBuffer {
constexpr const_iterator cend() const {
return data + size;
}
+
+#ifdef NDEBUG
+ constexpr
+#endif
+ T &operator[](size_type i) const {
+#ifndef NDEBUG
+ assert(i < size);
+#endif
+
+ return data[i];
+ }
};
#endif