
Noah Roberts wrote:
In article
, emildotchevski@gmail.com says... On Thu, Nov 5, 2009 at 4:08 PM, Noah Roberts
wrote: Consider something like so:
struct A { ...? };
struct B { std::list<A> items; };
struct C { A const* ptr_to_item_in_B_items; };
Possible? Impossible?
With the possible exception of the "const" this should work fine. In fact, the main demo included with the package and described in the tutorial does exactly this. For this to work, struct B would have to be serialized before struct C. If this is not done, one will get an exception since otherwise would endup with two copies of the original A. Assuming we avoid this trap, the tracking facility addresses this. As list<A> is saved, the addresses of all the A elements are saved. When (later) C is saved, only a reference to the original copy is saved. On loading its the same processess in reverse. All this happens without the programmer/user needing to do anything special other than make sure that the types are not "untracked". In almost all cases, the defaults will give the behavior desired without the programmer/user even being aware of it. Robert Ramey