2 ms·
> C != C++, because in the latter you can use smart pointers - just like in Rust. That's an overstatement. You can use smart pointers in C++, but they're not a
by naasking 10y ago
> C != C++, because in the latter you can use smart pointers - just like in Rust.
That's an overstatement. You can use smart pointers in C++, but they're not at all equivalent to the usability of Rust's pointer abstractions.
- jhasse 10y agoBut they are equivalent to smart pointers in Rust. For example even in Rust using std::sync::Arc can result in memory leaks just like in C++ with std::shared_ptr.
- steveklabnik 10y agoThey're not equivalent, though they are similar. For example, Rust is able to have the Rc/Arc split, allowing for increased performance in single-threaded code. You can't do that with shared_ptr, or at least, not in a way that's checked like in Rust.
- naasking 10y agoThey are not equivalent. For one, the Rust compiler checks that the references are properly initialized, passed around and dropped. C++ makes no such guarantees.