by duneroadrunner · 9y ago · 0 comments
#include "msemstdvector.h"
// ...
auto v = mse::mstd::vector<int> { 1, 2, 3 };
auto e = v.begin() + 0; // 'e' is a safe iterator here
// ...
v.push_back(v.size());
// ...
cout << *e << "\n"; // no problem
Not much different from your original code.Rust's policy of static enforcement of "exclusive mutable references" still might be preferable in many cases, but there is a practical option of using C++ in a safe(r) way.
No comments yet.