3 ms·
No, I'm not trolling, I'll give you the benefit of the doubt, try this C++: https://godbolt.org/z/zM3oxjrfn https://godbolt.org/z/zM3oxjrfn and contrast this
by tialaramex 1y ago
No, I'm not trolling, I'll give you the benefit of the doubt, try this C++:
https://godbolt.org/z/zM3oxjrfn https://godbolt.org/z/zM3oxjrfn
and contrast this Rust:
https://rust.godbolt.org/z/1rMYcqY65 https://rust.godbolt.org/z/1rMYcqY65
In your unique_ptr<T> example what you'd hidden (from me? Or perhaps from yourself) was that we're not destroying the unique_ptr, we're just destroying the Foo, and since the unique_ptr is null the destructor for that will be silent when the scope ends.