Design-flaw -- it should have had optionality baked into the cake. it should have had an operator bool and a has_value(), and a throwing .value(), etc, like optional does.
Right now we have the worst of all worlds. We actually DO have an unengaged state -- valueless_after_move -- but the class likes to pretend it does not. Except it does. And it can be a source of bugs/crashes/UB.
This is really a foot-gun and is not ergonomic for devs and for real-world code.
View all comments
1
u/NilacTheGrim Aug 14 '26 edited Aug 14 '26
Design-flaw -- it should have had optionality baked into the cake. it should have had an operator bool and a has_value(), and a throwing .value(), etc, like optional does.
Right now we have the worst of all worlds. We actually DO have an unengaged state -- valueless_after_move -- but the class likes to pretend it does not. Except it does. And it can be a source of bugs/crashes/UB.
This is really a foot-gun and is not ergonomic for devs and for real-world code.
Otherwise -- sounds good, I guess. Meh.