Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-05-12 20:43:47


boost::variant serialization is implemented in the next version (1.32) that
might work. If you want to make an implementation of boost::any
serialization that might work too.

In fact I think the way to go about this is to decide which of the above
suits you best and if it doesn't implement serialization, do it yourself!

Robert Ramey

Sean Kelly wrote:
> Dear All,
>
> I'm trying to figure out if something like the below is possible with
> the serialization library. The
> idea is to serialize a heterogeneous sequence using
> shared_pointer<void>.
>
> thanks for any help
>
> Sean
>
> void
> hetero_sequence()
> {
> // create and open a character archive for output
> std::ofstream ofs("dictionary.pickle");
> boost::archive::text_oarchive oa(ofs);
>
> std::deque<boost::shared_ptr<void> > sequence;
> sequence.push_back(boost::shared_ptr<string>(new string("random
> string")));
> sequence.push_back(boost::shared_ptr<double>(new
> double(3.1415627)));
> sequence.push_back(boost::shared_ptr<bool>(new bool(false)));
>
> // write class instance to archive
> oa << sequence;
> // close archive
> ofs.close();
> }


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