
On Sat, Jun 6, 2009 at 4:12 PM, Robert Ramey <ramey@rrsd.com> wrote:
So how could I verify whether an arbitrary pb1 and pb2 point to the same object or not?
If you want to check whether two shared_ptr objects p and q share ownership (that is, manage the same object), you can use: !(p<q) && !(q<p) However, you're probably asking with serialization in mind. I don't think serialization can support the most general shared_ptr use cases, since it supports aliasing: a shared_ptr<int> might point to an int within a larger object of user-defined type T. Obviously, when such shared_ptr is serialized what you want is to serialize the T, so you need some sort of cast-like operation to get to the T address, knowing the address of the int. Obviously this is not possible in general. (My last blog post might also be helpful in understanding shared_ptr better.) Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode