Subject: [std-proposals] function at() for span<> that throws exception on out-of-range, like vector and array ::at()
From: Roman Babinicz (rb_at_[hidden])
Date: 2019-11-28 05:37:05
Could we add operators at() to span<> container?
value_type & at(size_type n);
const value_type & at(size_type n) const;
they would have same behaviour as in vector, array - that is throws an
exception if n is outside of size of the container.
1) can we have that?
2) if yes, then should I write a proposal paper or how else to help in this?
Can it make it to C++20?
Imo it is a notable defect that span can not be a drop in replacement
for code taking a (reference to) array/vector that is using at().
By the way, in case of span that has specific size (not dynamic_extent)
we could perhaps have a static assert and the function might be constexpr.
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups