Boost logo

Boost :

From: Rozental, Gennadiy (gennadiy.rozental_at_[hidden])
Date: 2004-04-28 11:47:26

> > what if I do not save all of the shared_ptr to the same object?
> Here is a scenario:
> a) a shared_ptr exists and it points to and object which is
> pointed by 9 other shared_ptrs.
> b) we create and archive and save some objects. The set
> objects saved only includes 5 of the shared_ptrs out of the
> possible 10.
> c) later when we load, we create 5 new shared_ptr and one new
> object. Object tracking guarantees that only one shared
> object is created. As each new shared pointer is loaded, the
> shared count is incremented. So the new shared pointer is
> not identical to the original - its equal to 5.
> d) the process (almost?) guarantees that all the shared_ptr
> are valid in that they all point to shared object and the
> shared_count is maintained to be the correct number. The
> intention is that this process be exception safe
> - I'm not sure that this intention has been realized.

This is about how I expect it to work. But from this description it's

1. Why would you need to save counter into archive? After all value 10 has
nothing to do with resulting 5.
2. Why would you need direct access to shared_ptr counter? After all using
regular shared_ptr copy would automatically bump it to proper value.


Boost list run by bdawes at, gregod at, cpdaniel at, john at