r/cpp • • Aug 13 '26

C++26: std::indirect

https://www.sandordargo.com/blog/2026/08/12/cpp26-indirect
164 Upvotes

157 comments sorted by

View all comments

3

u/gracicot Aug 14 '26

I kinda wish hardened STL would cover indirect being null

5

u/jwakely libstdc++ tamer, LWG chair Aug 15 '26

It probably does (or should) in real implementations.

GCC hardens operator* with a not-valueless assertion. It doesn't harden operator-> because you just get a null pointer back if you call that on a valueless object. That might change to also harden operator->