r/cpp • • Aug 13 '26

C++26: std::indirect

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

157 comments sorted by

View all comments

Show parent comment

3

u/ts826848 Aug 14 '26

A moved-from optional<T> is still required to hold a T.

Oh, that is quite interesting! Looks like the paper did not propose destroying the moved-from value to disengage the moved-from optional for "performance reasons". Wonder how much of an impact that would have had.

However, you can use other invalid pointer bit patterns to encode optionals "empty" state, see my sibling comment.

Oh, true. I stand corrected! I think that makes the corresponding note in the paper a bit misleading, then, but it is what it is.