C++ Logo

std-proposals

Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 30 Nov 2019 05:15:30 +0200
On Sat, 30 Nov 2019 at 05:04, connor horman via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> If I may add my two cents, I think that adding a bounds checking access function to span, it would be useful in code that needs it, and won’t harm code that doesn’t. There are few cases where at is necessary, but in those cases, having it available is better than doing it yourself.

I agree wholeheartedly. Please be aware, though, that there's a
non-zero likelihood that some technical experts
who are adamant about at() being an abomination are going to resist
this idea regardless of the consistency
and migration paths it provides. Again, I don't personally agree with
them, and as far as design review
effort, specification effort, and implementation effort goes, a
span::at() is a drop in the ocean. Or rather
it would be, if only it were without the "thou shalt not ever perform
that operation" connotations that some
subscribe to.

The tirade I provided was mostly about "this paints C++ in a bad
light". The lack of at() in span doesn't
credibly do so.

Received on 2019-11-29 21:18:04