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

Show parent comment

12

u/Demiu Aug 14 '26

I allows for non-destructive move, that's why it has the valueless_after_move. Even if you have non-destructive moves that doesn't mean you have to introduce ability to be valueless before being moved, the language still has access modifiers and custom ctors, so you can force that it has to hold a valid value if ctor returned.

This is IMO better API design than old standard where everything doubled as an optional, like thread, function, streams and smart pointers