util/{Const,Writable}Buffer: add operator[]

This commit is contained in:
Max Kellermann
2014-03-01 07:25:17 +01:00
parent 9dc5335e3e
commit 4ba7427fa0
7 changed files with 41 additions and 19 deletions

View File

@@ -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