insert the following two lines at the beginng of your program
#include
Robert Ramey wrote:
The pimpl example demonstrates pretty much all I know about the issue.
Ok, I'm using that one now and it compiles fine.
But another issue appeared: The automatic serialization of nested std::vectors fails under certain circumstances. I managed to isolate the problem to the following case:
----------
// disable warnings that don't matter in this example #pragma warning(disable:4511 4512 4244 4100 4267)
#include
#include #include #include #include #include <fstream> #include <vector>
class A { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive &, const unsigned int) {} };
template<typename T> class B { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /*version*/) { //ar.register_type< std::vector<T> >(); // workaround A //ar & vT; // workaround B, part 1/2 ar & vvT; // this one fails }
//std::vector<T> vT; // workaround B, part 2/2 std::vector< std::vector<T> > vvT; };
void save() { std::ofstream ofs("test.dat"); boost::archive::text_oarchive oa(ofs);
B< boost::shared_ptr<A> > b_ptr_a; oa << b_ptr_a; }
void load() { std::ifstream ifs("test.dat"); boost::archive::text_iarchive ia(ifs);
B< boost::shared_ptr<A> > b_ptr_a; ia >> b_ptr_a; }
----------
The serialization of std::vector< std::vector<T> > fails to compile (VC++ 7.1) unless one of the workarounds is used, that means some kind of registration of std::vector<T>. Is that a known limitation? I found nothing in the documentation about this case, but perhaps I overlooked something.
Malte