Serialization of char*
The code below won't compile for me using VC8. Can someone explain? I'm
sure I'm doing something dumb, but I'm too dumb to know what.
#include
Sorry for the noise. I retract my posting. I probably still have a question, but it's not the one below. Deane Yang wrote:
The code below won't compile for me using VC8. Can someone explain? I'm sure I'm doing something dumb, but I'm too dumb to know what.
#include
#include <iostream> #include <fstream> struct Object { char* ptr; };
int main (int argc, char* argv[]) { try { std::cout << "Saving portfolio to archive...\n"; Object object; object.ptr = new char[10]; for (int i= 0; i < 10; ++i) { object.ptr[i] = 'i'; } std::ofstream ofs(filename); assert(ofs.good()); boost::archive::xml_oarchive oa(ofs); const Object& obj(object); oa << BOOST_SERIALIZATION_NVP(obj); } catch (const xml_schema::exception& e) { std::cerr << e << std::endl; return 1; } }
So after banging my head against a wall for the last two days, I have finally discovered that direct serialization of char* is not allowed, but you can do it if you use "make_binary_object". I am just curious about where this is stated in the documentation.
participants (1)
-
Deane Yang