Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-08-14 00:04:37


Jan Tinkhof wrote:
> Hello all,
>
> I'm currently trying to make a library serializable and would like to
> be as non-intrusive as possible.
>
> Unfortunately this library (ODE) uses its own forms of linked lists to
> manage its objects and the links include a
> "pointer-to-pointer-to-type" (type**).
>
> How do I go about serializing these? Why doesn't this compile?
>
>
>
> #include <fstream>
> #include <boost/archive/text_oarchive.hpp>
>
> struct mystruct {
> int i;
> };
>
> template<class Archive>
> void serialize(Archive& ar, mystruct& ms, const unsigned int version)
> {
> ar & ms.i;
> }
> BOOST_CLASS_TRACKING(mystruct, boost::serialization::track_always)
>
> int main( int argc, char* argv[], char* envp[] )
> {
> std::ofstream ofilestream("filename.txt");
> boost::archive::text_oarchive oarchive(ofilestream);
>
> mystruct a;
> mystruct* pa = &a;
// *** replace this
// mystruct** ppa = &pa;
// *** with this
mysturct ** const ppa = &pa;

> oarchive << ppa;
>
> }

*** read the rationale section on why this trap occurs.

Robert Ramey


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