#include #include #include #include #include #include #include #include //#define USE_VECTOR_TRICK int main() { std::string str="Hello world"; str[5]='\0'; const std::string& str0=str; { std::ofstream ofs("pepe.txt"); boost::archive::text_oarchive oa(ofs); #ifdef USE_VECTOR_TRICK std::vector buf(str.begin(),str.end()); const std::vector& cbuf=buf; oa< buf(str.begin(),str.end()); ia>>buf; str1.assign(buf.begin(),buf.end()); ia>>buf; str2.assign(buf.begin(),buf.end()); #else ia>>str1; ia>>str2; #endif } assert(str1[5]=='\0'); assert(str0==str1&&str0==str2); std::cout<<"OK"<