C++ Logo

std-proposals

Advanced search

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

From: Lyberta <lyberta_at_[hidden]>
Date: Sat, 30 Nov 2019 20:09:00 +0000
Ville Voutilainen:
> I would otherwise have sympathy for that, but WTF Lyberta, I did 2
> instead of 3.

Yeah, sure. But that takes mental resources that are already scarce.

> that the 2/3 difference
> scales when you have a range; it's 2, as opposed to N, depending on
> how many accesses you have.

In my experience array indexes mostly come from sockets or files and
there is rarely more than one index in a single function. The rest are
iterators.

> I.. don't see how unsafe_at walked into this discussion. Perhaps
> that's my mistake, honestly,
> but I thought this was about adding at() in span because it's already
> present in vector and array.
>

I wanted to point out that making std::span API compatible with
std::vector and std::array is still not ideal. But that would be a
discussion for something like C++29.


Received on 2019-11-30 14:12:11