3 ms·
I thought moving will leave the original in some valid state. For example moving a vector may leave the original object as an empty vector. What's so broken abo
by ant6n 11y ago
I thought moving will leave the original in some valid state. For example moving a vector may leave the original object as an empty vector. What's so broken about that?
- catnaroek 11y agoSometimes there is no valid state for a `std::move`d object, e.g. a `std::unique_ptr`.
- ant6n 11y agoWouldn't just be nullptr?
- catnaroek 11y agoThe very concept of a nullable pointer is problematic, because it means that every dereference operation is potentially unsafe. The only satisfactory solution is to enforce, using the type system, the rule that moved objects can't be reused. Unfortunately, C++'s type system can't express this.