2 ms·
Pragmatically though I don't use either because they are wrapped up in data structures. With copy elision and move semantics memory basically does become autom
by CyberDildonics 11y ago
Pragmatically though I don't use either because they are wrapped up in data structures. With copy elision and move semantics memory basically does become automatic on a day to day basis.
When I am making my own data structures I basically use unique_ptr or just use std::vector directly.
I've used shared_ptr in one relatively exotic situation and no other time.
I'm actually not even sure what you mean when you say use after free - I rarely expose a naked pointer, and when I do the lifetime and ownership are pretty obvious.
I like Rust and I'm not trying to downplay its significance, but I think you are misjudging the reality of working in C++11 - memory leaks and use after free don't seem to be an issue to me after having done nothing but C++11 for three years.
- pcwalton 11y ago> I'm actually not even sure what you mean when you say use after free - I rarely expose a naked pointer, and when I do the lifetime and ownership are pretty obvious. Reference and iterator invalidation, usually. > I think you are misjudging the reality of working in C++11 - memory leaks and use after free don't seem to be an issue to me after having done nothing but C++11 for three years. It continues to be an issue for us and every other browser vendor, despite widespread adoption of C++11 throughout the codebase. Large C++ apps that are believed immune to UAF typically just haven't been the target of people actively looking for holes.