Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can't accidentally pass a shared pointer to a library function in C++. You'd get a compiler error. Then you'd pass the pointer within the smart pointer and make sure the case was handled appropriately. It's not hard and it's definitely still worth it to liberally use shared_ptr.


You can't "accidentally" do it; it's just that the only way to actually do it in practice is fundamentally unsafe. "It's not hard"? You know what else isn't hard? Making sure you don't treat an integer as signed in one place and unsigned in another. There's $1.5Bn USD of "not hard", right there.


>You can't accidentally pass a shared pointer to a library function in C++.

Spoken like someone who has never used a template function.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: