
17 Sep
2011
17 Sep
'11
2:47 p.m.
On Saturday, September 17, 2011, John M. Dlugosz wrote:
I guess that is what I'm trying to figure out. If two smart pointers manage the lifetime of the same entity, how can they not get() the same pointer? I see that they might be different addresses if they refer to the object by different types, but that is true for regular pointers, and bringing them to a common base class would allow them to compare equal.
shared_ptr also has an aliasing copy constructor, where you can give it an arbitrary pointer. So, you might make a shared_ptr that points at a struct and a shared_ptr that points at a member of the same struct, but they both share the same reference count and deleter.