3 ms·
> C++ has a standard library and smart pointers that eliminate a lot of errors with dangling pointers, and if people use those exclusively You can't use smart
by dureuill 4y ago
> C++ has a standard library and smart pointers that eliminate a lot of errors with dangling pointers, and if people use those exclusively
You can't use smart pointers exclusively, because there is no "smart observational pointer", and there cannot be one, because that would be a reference type checked by a borrow checker, which is exactly what rust uses.
You can emulate it with shared pointers, but then you're left with basically a reference counted language. Why not using swift at this point? Also this creates a semantic impedance mismatch that tends to manifest with cycles.
Source: walked a codebase that would (ab)use shared pointers
- ActorNightly 4y agoThe point is you can still write memory safe code and avoid all the double free and user after free bugs if you just use smart pointers correctly and standard namespace constructs. You can be extra safe and use unique pointers and transfer ownership. Sure, there are some things that Rust makes nice, like compile time checking for errors, however with C++ codebases, they will just result in runtime errors rather than usable exploits.