Subject: Re: [std-proposals] function at() for span<> that throws exception on out-of-range, like vector and array ::at()
From: Nevin Liber (nevin_at_[hidden])
Date: 2019-11-30 14:00:18
On Sat, Nov 30, 2019 at 1:21 PM Lyberta via Std-Proposals <
> Anyway. My fundamental opinion is that operator should do bounds
> checking while unsafe_at() should not because it is clearly named unsafe.
Should all functions which have preconditions on calling them be named
unsafe_***? I would not want to call unsafe_dereference(ptr) instead of
*ptr each and every time I needed to dereference it (for example). I'm
generally against verbosity for common cases.
IMO, at() was a mistake, as the number of people who call it in the name of
"defensive programming" far outweighs the few that call it to sanitize
However, that ship sailed over two decades ago.
IMO, at() should be added to span for the sake of consistency with other
It may be a battle because some folks (not I) view span as the time to
rethink the interface.
As someone who has already fought multiple battles for span, it would take
a lot to goad me into presenting such a paper. I would, however, be likely
to support such a paper should it be presented to the committee.
IMO, it is way too late to try and get this added to C++20.
-- Nevin ":-)" Liber <mailto:nevin_at_[hidden] <nevin_at_[hidden]>> +1-847-691-1404
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups