Comment by pornel

4 days ago

BTW, Rust's lifetime annotations for borrowed references are a mostly orthogonal feature.

Liveness of objects for move/drop semantics is tracked differently, without any syntax and with implicit runtime drop flags where necessary.

C++ could probably add the same deinitialized/moved-from state tracking (with an opt-in for back compat sake) purely to avoid dtor bloat, without having to add safety of borrow checking.

> C++ could probably add the same deinitialized/moved-from state (with an opt-in for back compat sake) purely to avoid dtor bloat, without having to add safety of borrow checking.

There is a lot of talk in the C++ committee about this. The details are complex in some obscure cases.

  • At the very leas you'd also need to fix the caller-destructed ABI mess to get a 100% solution.