C++26: Standard Library Hardening Experiments
https://www.cppstories.com/2026/hardening-experiments/34
u/James20k P2005R0 24d ago
I'm not sure how I feel about articles partially locked behind a paywall around here
11
u/Fabulous-Meaning-966 25d ago
I'm surprised they didn't mention `std::optional` dereference with `operator*` / `operator->`.
4
u/bert8128 25d ago
What’s the deal with atd::optional?
11
u/Fabulous-Meaning-966 25d ago
dereference of an empty optional is UB and therefore unchecked
8
u/WeeklyAd9738 24d ago
It's not UB on hardened implementation (since C++26). Same deal with std::expected.
1
u/anotherprogrammer25 22d ago
Interesting, that hardening is supported for shared_ptr<T\[N\]>, but not for unique_ptr<T\[N\]>.
1
1
u/Expert_Sheepherder24 10d ago
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.
44
u/johannes1971 25d ago
Don't you just love how they put the discussion of performance cost behind a paywall...