| ▲ | sprocketz 5 hours ago | |||||||
And the most important idea: destructive moves. Since C++ doesn't track lifetimes it has to leave the object in a "valid state" after a move and the destructor still runs which has to have a check if it should do something or not. | ||||||||
| ▲ | jandrewrogers an hour ago | parent | next [-] | |||||||
While not the common case, C++ move semantics match the situation in systems code where correctness requires decoupling logical object lifetimes and destructors. The object is logically dead but the destructor may be deferred indefinitely for safety reasons. Most code doesn't have the shared memory setups where deferred destruction is necessary. | ||||||||
| ▲ | pornel 3 hours ago | parent | prev [-] | |||||||
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. | ||||||||
| ||||||||