3 ms·
C++ "smart pointers" share with threads a common risk: most people using them should avoid using them.
by faragon 9y ago
C++ "smart pointers" share with threads a common risk: most people using them should avoid using them.
- emsy 9y agoI contend that most people that will cause trouble with smart pointers will also cause trouble with manual memory management, so your point is moot.
- faragon 9y agoPeople not understanding manual memory management should not write C++ at all, in my opinion.
- TillE 9y ago"Most people" using new/delete with raw pointers = memory leaks and crashes, guaranteed. unique_ptr and shared_ptr are really simple and incredibly useful. If you're too scared to use them, you should not be using C++ at all.
- faragon 9y agoWell, I'm using C++ since 1993, so go figure.
- BrandonLive 9y agoSpoken like someone who understands neither?
- faragon 9y agoOne thing is using smart pointers "a la RAII", and another, "creative, a la dangerous, usage". E.g. some of the risks of using smart pointers from a previous HN discussion: https://news.ycombinator.com/item?id=11698784 https://news.ycombinator.com/item?id=11698784