|
Boost Users : |
Subject: [Boost-users] [Serialization] [Ptr_container] Serializing a boost::ptr_vector fails
From: Philipp Münzel (mailing-lists_at_[hidden])
Date: 2011-06-17 10:18:26
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