r/cpp • • Sep 11 '26

C++26: Standard Library Hardening Experiments

https://www.cppstories.com/2026/hardening-experiments/
25 Upvotes

12 comments sorted by

43

u/johannes1971 Sep 11 '26

Don't you just love how they put the discussion of performance cost behind a paywall...

-19

u/bert8128 Sep 11 '26

If you’re not paying for the product then you are the product.

-14

u/bert8128 Sep 12 '26

Interesting that I have got some down votes for this. I like free too, but just remember that everything has a cost. None of this stuff is actually free. Someone somewhere is paying for it.

0

u/[deleted] Sep 12 '26

[deleted] — view deleted comment

-8

u/bert8128 Sep 12 '26

The point is that there is an actual cost, so don’t complain that there are things you have to pay for. You wouldn’t work for free, so don’t expect others to. There is a general expectation that everything will be supplied for free, but that is clearly unsustainable. Perhaps by putting part of the information behind a paywall there is less mining of your data (which is where you are then product comes in to play). Sadly I doubt it, but at least it’s a possibility.

34

u/James20k P2005R0 Sep 12 '26

I'm not sure how I feel about articles partially locked behind a paywall around here

10

u/Fabulous-Meaning-966 Sep 11 '26

I'm surprised they didn't mention `std::optional` dereference with `operator*` / `operator->`.

4

u/bert8128 Sep 11 '26

What’s the deal with atd::optional?

10

u/Fabulous-Meaning-966 Sep 11 '26

dereference of an empty optional is UB and therefore unchecked

8

u/WeeklyAd9738 Sep 12 '26

It's not UB on hardened implementation (since C++26). Same deal with std::expected.

1

u/anotherprogrammer25 Sep 14 '26

Interesting, that hardening is supported for shared_ptr<T[N]>, but not for unique_ptr<T[N]>.

1

u/Baardi Sep 18 '26

Unique_ptr is only a thin wrapper over a raw pointer. They probably wanted to avoid different behaviour between raw/unique pointers

1

u/Expert_Sheepherder24 Sep 26 '26

because unique_ptr<T[N]> you can declare, but can't defined and initialize ).
unique_ptr<T[]> exists, but it didn't know our size, shared_ptr<T[]> also not hardened.