Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] [Ptr_container] Serializing a boost::ptr_vector fails
From: Philipp Münzel (mailing-lists_at_[hidden])
Date: 2011-06-17 10:22:38


I'm sorry, I simply forgot to

#include <boost/ptr_container/serialize_ptr_vector.hpp>

please excuse the disturbance.

Regards,
Philipp

On 17.06.2011 16:18 "Philipp Münzel" <mailing-lists_at_[hidden]>
wrote:
> Dear list,
>
> I want to use boost::ptr_vector<> in conjunction with
> boost::serialization.
> The ptr_cotainer documentation says:
>
> > As of version 1.34.0 of Boost, the library supports serialization
> > via Boost.Serialization.
> > Of course, for serialization to work it is required that the stored
> > type itself is serializable. For maps, both the key type and the
> > mapped type must be serializable.
>
> However, when I create a class like this:
>
> #include <boost/ptr_container/ptr_vector.hpp>
> #include <boost/serialization/access.hpp>
>
>
> class Foo {
> boost::ptr_vector<int> the_vector_
> friend class boost::serialization::access;
>
> template<class Archive>
> void serialize(Archive & ar, const unsigned int)
> {
> ar & the_vector_;
> }
> }
>
> and then try to serialize it:
>
> std::ofstream ofs("filename");
> Foo f;
> boost::archive::text_oarchive oa(ofs);
> oa << f;
>
> I'm getting the following error, using gcc 4.2.1 and boost 1.46.1:
>
>
> /usr/local/include/boost/serialization/access.hpp:118: error: 'class
> boost::ptr_vector<Waypoint, boost::heap_clone_allocator,
> std::allocator<void*> >'
> has no member named 'serialize'
>
> How can I serialize a boost::ptr_container ?
>
> Regards,
> Philipp
>


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