For indirect the cardinality should be 1 instead of 0-1. The valueless_after_move() state is just an artifact of C++'s move semantics.
It's the same reason a variant<Red, Blue> really just is the union of all possible Red and all possible Blue values, despite the existence of the valueless_by_exception() state.
Doh, well in that case, std::indirect may not be quite what I need for my scenarios, because I basically want an optional except the space is not wasted when the heavy object isn't present, where empty is a valid object state. Then guess I'll keep my copyable_ptr class still. Added a new row in the table ⬆️.
View all comments
Show parent comment
17
u/jiixyj Aug 14 '26
For
indirectthe cardinality should be1instead of0-1. Thevalueless_after_move()state is just an artifact of C++'s move semantics.It's the same reason a
variant<Red, Blue>really just is the union of all possibleRedand all possibleBluevalues, despite the existence of thevalueless_by_exception()state.