Subject: Re: [std-proposals] function at() for span<> that throws exception on out-of-range, like vector and array ::at()
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2019-11-28 06:32:55
On Thu, 28 Nov 2019 at 13:37, Roman Babinicz via Std-Proposals
> 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.
I predict this to be an uphill battle. Some audiences think that at()
should have never been
in vector, and adding it to array was a mistake, and that that mistake
any further. I would guess that some such audiences are co-authors of span.
Personally, I think they're wrong, but I'm just giving you a heads-up
that this is not going to be
a trivial sale.
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups