C++ Logo

std-proposals

Advanced search

Re: function at() for span<> that throws exception on out-of-range, like vector and array ::at()

From: Bjorn Reese <breese_at_[hidden]>
Date: Sat, 30 Nov 2019 16:43:59 +0100
On 2019-11-30 11:15, Eyal Rozenberg via Std-Proposals wrote:
> What are the arguments against "at()", other than possibly being redundant?

That it brings in exceptions, which are disable in many real-time and
embedded projects.

For instance P0829 proposes to remove std::array<T>::at() in
freestanding mode.

I reckon that the most viable approach forward is to introduce a free
std::at() function, similar to std::get(). This makes it possible to
have bounds check for types that do not support them, such as C arrays
or std::span.

Received on 2019-11-30 09:46:23