News for hackers. Stuff that matters.
Re:Some were meant for C [pdf] by tialaramex on Wednesday June 21, 2023 @07:43PM (#36426309)
C++ 20 std::span is an example of how little WG21 actually cares about safety, correctness or other principles of software engineering.

The slice type you actually want has nice safety properties. The slice type proposed to WG21 about five years ago as std::span compromises a little bit, knowing they'd object to good engineering here, and it offers an unsafe way to access the slice as well as safe access. The committee voted to strip out safe access and specifically rejected efforts to ensure there was a sane way to use this type.

I assume Jarrad Waterloo's proposal to fix std::span in C++ 26 will get traction because it's now embarrassing for the project but there's no reason we should pretend this was some mere oversight. C++ is less safe than it should be on purpose.

Re:Some were meant for C [pdf] by MereInterest on Wednesday June 21, 2023 @07:56PM (#36426429)
I get similarly frustrated at the implementation of operator-> and operator* in std::optional. In what world would I want to provide accessors with no more safety than a raw pointer?

Edit: I was looking it up just to make sure I remembered it correctly, and there’s been a recent change that makes it worse. The operator-> and operator* on std::optional are now marked noexcept, so implementations are forbidden from making the accessors safe.

https://cplusplus.github.io/LWG/issue2762

Re:Some were meant for C [pdf] by steveklabnik on Wednesday June 21, 2023 @07:53PM (#36426402)
That's what I've heard, but since I'm not that in the weeds with that whole process, I didn't want to comment on it at that level.

It's struck me as being similar to operator* on Optional. I get why they did it. It makes sense. It's also unfortunate. I'm glad I'm not on that committee.