Hacker News new | ask | show | jobs
by albinofrenchy 3212 days ago
The point about legacy pointer code is valid, but the benefit of the newer pointer / iterator / ownership stuff isn't really that it is in and of itself a magic bullet.

What it does do is make it easy to reason about how pointers are used across the application. Also worth noting that even with legacy libraries, you can wrap a given pointer with std::unique_ptr or std::shared_ptr and provide a custom deleter and maintain reasonable safety guarantees.

1 comments

I do get it's easier. I use std::unique_ptr when interfacing with legacy code because I like that I need an explicit .release() to relinquish ownership. It's self-documenting.

But I was considering modern C++ compared to, for example Rust. I'm not sure if the memory safety issue that Rust solves still exists as strongly with a purely modern C++ codebase...but then again I never run into those either.

For threads it's no contest between Rust and C++, although TSAN is pretty damn nice.