Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] Serializing a vector of pointers
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-07-02 11:48:20


Dante Stroe wrote:
> Hello,
>
> I am trying to serialize a vector of pointers (Below you have a piece
> of dummy code that reproduces the error) but I get compilation errors.
> As I understood from the tutorial this should pretty much work out of the
> box. Am I missing something? I am using gcc 4.1 and the 1.43 version
> of the boost library.
>
> Thanks a lot,
> Dante
>
> Test program:
>
> #include<cstddef>
> #include<iomanip>
> #include<iostream>
> #include<fstream>
> #include<vector>
> #include<boost/archive/tmpdir.hpp>
> #include<boost/archive/text_iarchive.hpp>
> #include<boost/archive/text_oarchive.hpp>
> #include<boost/serialization/vector.hpp>
> #include<boost/serialization/utility.hpp>
>
> class test
> {
> friend class boost::serialization::access;
> std::vector<double*> r; // = std::vector<double*>(n);
> template<class Archive>
> void serialize(Archive& ar, const unsigned int
> /*file_version*/){ ar& r;
> }
> public:
> test(){};
> };
>

I'm guessing that there is a problem serializing a pointer to a double which
is a primitive.

This is inhibited as it tends to have undesired side effects. You might
try a strong type or serialization of a class which contains nothing but a
double.

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