Boost logo

Boost Users :

Subject: [Boost-users] [serialization] Stop tracking a specific item
From: Chard (boost_at_[hidden])
Date: 2009-08-25 16:25:40


I have no access to the default constructor of a type I want to serialize
(and no knowledge of any other constructors). However, the type is a friend
to boost::serialization::access.

Rather than duplicating a chunk of the serialization code, I thought I could
just reuse the guts of it by serializing the object through a pointer.

However, this would require me to construct the pointer during the
serialization process, which would mess up the object tracking. Is it
possible to turn the tracking off for a specific serialized object, but not
the whole type ?

E.g. a contrived example:

template ...
void serialize(Archive &ar, const unsigned)
{
  Type *p = 0;

  if (Archive::is_saving::value)
  {
    p = FuncThatCanGiveMeAPointerToType();
  }

  // Want to turn off object tracking on p here
  ar & p;
  // or remove it here

  if (Archive::is_loading::value)
  {
    FuncThatCanAssignTypeByValue(*p);
    delete p;
  }
}

It's like I require a remove_object_address, as opposed to
reset_object_address.

Or is there an alternative approach?


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