3 ms·
Is shared_ptr a zero cost abstraction?
by nemothekid 7y ago
Is shared_ptr a zero cost abstraction?
- kam 7y agoMostly, with the caveat that in single threaded usage, you're paying for the unnecessary overhead of atomic ops on the reference count. Rust has `Rc`, which is not atomic but `!Send` so the type system ensures that it stays within a thread, as well as the atomic `Arc`.