0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::vector_view: Add assertion for bounds check here.

This commit is contained in:
Jason Volk 2019-08-14 21:55:49 -07:00
parent 0aacf44440
commit 7420bf1156

View file

@ -46,15 +46,21 @@ struct ircd::vector_view
iterator begin() { return data(); }
iterator end() { return _stop; }
// Bounds check in debug only.
value_type &operator[](const size_t &pos) const
{
assert(pos < size());
return *(data() + pos);
}
// Bounds check at runtime.
value_type &at(const size_t &pos) const
{
if(unlikely(pos >= size()))
throw std::out_of_range("vector_view::range_check");
throw std::out_of_range
{
"vector_view::range_check"
};
return operator[](pos);
}