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:15:00 +0000
Nevin Liber via Std-Proposals:
> 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.

Sure, a better solution would be Rust unsafe blocks. So you would write
dereference like this:

unsafe
{
 auto value = *ptr;
}

But that requires going through entire language to split it into safe
and unsafe parts.


Received on 2019-11-30 14:17:49