|
|
|
|
|
by cristicbz
3886 days ago
|
|
You can still trigger plenty of undefined behaviour in C++11 with no raw pointers. Just one example--iterator invalidation: auto v = std::vector<int> {1, 2, 3}
for (auto x : v) {
if (x > 0) {
v.push_back(-x);
}
}
The above may segfault, do what you expect it to, run forever etc. Unchecked indexing, branching on uninitialized data etc.Rust frees you from _all_ of these things and offers a bunch of further advantages, most notably: data race freedom. You can actually share data between threads and keep your sanity. |
|