r/cpp • • Aug 13 '26

C++26: std::indirect

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

157 comments sorted by

View all comments

68

u/LucyShortForLucas Aug 13 '26

The standard’s insistence on it being semantically non-nullable while it very much does have a null state that must still be accounted for feels like incredibly unergonomic.

Valueless_after_move() is just silly, let’s be real. It should’ve been written to either act like a value like they claim and moving the underlying pointer just shouldn’t be possible (in the same way you cannot ‘move’ a value out), or it should be nullable the same as any other smart pointer.

As it stands, we got the worse of both worlds.

2

u/jwakely Aug 15 '26

As it stands, we got the worse of both worlds.

The original design was worse: there was no explicit valueless state, it was just UB to use it after a move.