2 ms·
> and it will be just as safe as you write it in C C++ standard library containers have guarantees about iterators and pointers invalidation, e.g. std::list ne
by Const-me 8y ago
> and it will be just as safe as you write it in C
C++ standard library containers have guarantees about iterators and pointers invalidation, e.g. std::list never invalidates any of these, unordered_map invalidates iterators when rehashed and never invalidates pointers to either keys or values. This allows building unsafe data structures on top of standard collections, and then compose custom unsafe data structures on top of each other.
This makes C++ both safer (at least from memory leaks) and easier to use compared to unsafe rust.