3 ms·
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 an
by kingkongrevenge 18y ago
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.
- tptacek 18y agoYou 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.
- anewaccountname 18y ago>You can't accidentally pass a shared pointer to a library function in C++. Spoken like someone who has never used a template function.