3 ms·
> to ensure correct lifetimes Refcounted pointers don't make that guarantee. They just guarantee that if they are incorrect they will not deallocate (== will
by gumby 4y ago
> to ensure correct lifetimes
Refcounted pointers don't make that guarantee. They just guarantee that if they are incorrect they will not deallocate (== will leave garbage) and thus never result in a use-after-deletion.
Most of the time they are fine but they can't handle circular structures. This is why C++ has the weak_ptr.
- PaulDavisThe1st 4y agoNo use-after-deletion is precisely what is required. And yes, we use weak_ptr too, for some things. The alternative is "no language-level references, any time you want object "Foo", go look it up in some table". We opted not to do that.