4 ms·
No you don't. If you did you could just call free. You know one of the decrements will do it, but not which one.
by wbl 3y ago
No you don't. If you did you could just call free. You know one of the decrements will do it, but not which one.
- Karellen 3y agoGood point. I was thinking of a lot of cases where RC is being used as a general solution for lifetime management with automatic refcounting; but most objects have a well-known lifetime with their refcount being 1 95% of the time. And another 4% have their refcount bump up to 2 briefly when they're temporarily shared, or transferred to a new owner (think returning a shared_ptr<>). But, yeah, the "genuinely shared" case - either the 1% in the scenario above, or when RC is only being used for objects with complex lifetimes - is definitely a significant use-case I overlooked.