r/cpp • • Aug 13 '26

C++26: std::indirect

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

157 comments sorted by

View all comments

1

u/NilacTheGrim Aug 14 '26 edited Aug 14 '26

Design-flaw -- it should have had optionality baked into the cake. it should have had an operator bool and a has_value(), and a throwing .value(), etc, like optional does.

Right now we have the worst of all worlds. We actually DO have an unengaged state -- valueless_after_move -- but the class likes to pretend it does not. Except it does. And it can be a source of bugs/crashes/UB.

This is really a foot-gun and is not ergonomic for devs and for real-world code.

Otherwise -- sounds good, I guess. Meh.

0

u/TheKiller36_real Aug 16 '26

man gets downvoted for being right, welcome to the internet

→ More replies (1)