Boost logo

Boost Users :

From: martin f krafft (madduck_at_[hidden])
Date: 2005-05-11 08:58:49


also sprach Robert Ramey <ramey_at_[hidden]> [2005.05.11.0826 +0200]:
> This should work - How is your case different that test_cycle.cpp ?

If you are talking about test_cyclic_ptrs.cpp, how does that
actually show that it works? It just states in a comment that it
cannot be made to work, and the test_main code actually assumes that
it won't work:

  BOOST_CHECK(
      exception.code == boost::archive::archive_exception::pointer_conflict
  );

> The pointer conflict means that something has been serializaed as
> first as a pointer then as an object. Normally this should be
> easily avoidable.

What about the cases when it's not easily avoidable? In a related
thread, I asked the question of how to serialise a linked list.

  node::serialize()
  {
    if (this->next) serialize *(this->next);
    serialize this->next;
  }

this (recursive) approach will work (I think). But what if I have to
use iteration? Or if I serialise a graph, where a number of pointers
to a node may exist? Do I really have to go through the lengths to
ensure that the Nodes are serialised first?

> This is flagged as an error because the de-serialization would be
> a problem. First the deserialization of a pointer creates an
> object - next the object itself is re-loaded - but now we have two
> objects when we started with one.

Couldn't it just assign the already-created object to the
non-pointer? From what I understand, serialising *P then P is the
same as serialising P then *P: the first time, the entire object is
dumped. The second time, a reference is written instead. Thus, on
first creation, everything is already known about the object. And
when the non-pointer needs to be serialised, then we don't return
a pointer, but a reference...

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net_at_madduck
 
invalid/expired pgp subkeys? use subkeys.pgp.net as keyserver!
spamtraps: madduck.bogus_at_[hidden]
 
scientists will study your brain to learn
more about your distant cousin, man.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net