aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/gprpp
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2018-01-23 14:57:11 -0800
committerGravatar Mark D. Roth <roth@google.com>2018-01-23 14:57:11 -0800
commit9ab4d0c82699064efebd8a15eebf66e3db8bf256 (patch)
treefd6a532ef1e1580572da8f55811b819a5f03f5f5 /src/core/lib/gprpp
parent19688bf7a8b8b172faeba347d81d9b6cafecb874 (diff)
Add const version of operator[].
Diffstat (limited to 'src/core/lib/gprpp')
-rw-r--r--src/core/lib/gprpp/inlined_vector.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/lib/gprpp/inlined_vector.h b/src/core/lib/gprpp/inlined_vector.h
index 55ba77debd..8044c682d1 100644
--- a/src/core/lib/gprpp/inlined_vector.h
+++ b/src/core/lib/gprpp/inlined_vector.h
@@ -61,6 +61,15 @@ class InlinedVector {
}
}
+ const T& operator[](size_t offset) const {
+ assert(offset < size_);
+ if (offset < N) {
+ return *reinterpret_cast<const T*>(inline_ + offset);
+ } else {
+ return dynamic_[offset - N];
+ }
+ }
+
template <typename... Args>
void emplace_back(Args&&... args) {
if (size_ < N) {