Quote:Original post by NotAYakk
No?
shared_ptr means that any object with a shared_ptr reference to the thing in question can extend it's lifetime.
Ah, I'm just looking at things a different way; a shared_ptr will keep the thing alive until the last bit of code that uses it has dissappeared. So while you would say that code is keeping it around, I would say that shared_ptr ensures that the life of a resource is as short as it safely can be (if used carefully).
Quote:shared_ptr uses pointer semantics on assign. Ie, a = b means that a points to what b pointed to, and a constructed from b means a refers to the same thing as b.
Reference semantics a=b means what a points to is given the value of what b points to, and a constructed from b means that a refers to the same thing as b.
I tend not to distinguish between pointer and reference semantics and lump them under the same "referring to the same underlying object once constructed" heading.
as the value of b.
Quote:pointer semantics != reference semantics != value semantics.
It's a language difference. I agree with what you are saying, I'm just not as rigorous with my definitions as I might be.
Quote:Lastly, shared_ptr is a reference counted pointer, not a garbage collected pointer.
Some people would classify reference counting as a naive kind of garbage collection (hence the "depending on one's definition of garbage collection" part); if the definition of garbage collection is to release a resource when nothing is referring to it any longer, reference counting would fall under it (in cycle-free situations).
Yeah, so I'm in agreement. I will go away now :)