Its class invariants, yes. But not whatever other invariants that may rely on that object.
You can always bring it back to a specified state.
You can do that will indirect and polymorphic, too. It's the only thing you can do, just like with any other object.
This is entirely a different animal than intentional UB.
Not sure what the word "intentional" is doing there, but unpredictable behavior in your own program is really not that different from UB in the language.
I'm saying that std::indirect would have been much better had it explicitly modeled the unengaged state
No, that would've been terrible, because it would've forced you to check before every access. It's a value, not an optional<value>. As it is, you don't do that check, just like you don't check every other object -- which will also lead to disaster if accessed after move.
View all comments
Show parent comment
6
u/wyrn Aug 14 '26
Its class invariants, yes. But not whatever other invariants that may rely on that object.
You can do that will
indirectandpolymorphic, too. It's the only thing you can do, just like with any other object.Not sure what the word "intentional" is doing there, but unpredictable behavior in your own program is really not that different from UB in the language.
No, that would've been terrible, because it would've forced you to check before every access. It's a value, not an
optional<value>. As it is, you don't do that check, just like you don't check every other object -- which will also lead to disaster if accessed after move.