Opened 14 years ago
Last modified 14 years ago
#2326 assigned Bugs
Library does not directly support serializing data of type "foo**"
Reported by: | anonymous | Owned by: | Robert Ramey |
---|---|---|---|
Milestone: | Boost 1.37.0 | Component: | serialization |
Version: | Boost 1.36.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The following example fails to compile, trying to find a .serialize() member function in an int*. Clearly the user can program around this, but serializing pointers-to-pointers seems a natural capability that should be in the library.
#include <fstream>
#include "boost/archive/text_oarchive.hpp"
class foo {
friend class boost::serialization::access;
template<class archive>
void serialize(archive& ar, const unsigned int version) {
ar & BOOST_SERIALIZATION_NVP(buff);
ar & BOOST_SERIALIZATION_NVP(ptr);
}
public:
foo() : ptr(&buff[3]) {}
int* buff[10];
int ptr;
};
int main() {
foo f;
std::ofstream serial("serial");
boost::archive::text_oarchive oa(serial);
oa << BOOST_SERIALIZATION_NVP(f);
return 0;
}