Hacker News new | ask | show | jobs
by 5hoom 4440 days ago
What problems have you found trying to write memory safe code?

It seems to me that you barely have to think about memory ownership anymore ever since unique_ptr and shared_ptr came along.

1 comments

I suppose my main gripes are that moving is not free, you can reuse moved-from objects, and there is no story for checked borrowing of unique_ptrs—you have to use raw pointers or weaken the ownership semantics to shared_ptr so that you can use weak_ptr for safe borrowing. Not to mention that shared_ptr is often semantically questionable and used as an inefficient alternative to a garbage collector.
Fair enough, good answer :)