首页 > 代码库 > boost::archive::binary_iarchive
boost::archive::binary_iarchive
#include <iostream> #include <string> #include <sstream> #include <vector> #include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <queue> #include <boost/serialization/vector.hpp> using namespace std; struct MyStruct { string stru; int len; }; queue<MyStruct> q_stu; void funa() { MyStruct ms; int ret = 1; vector<int> vc; vc.push_back(1); vc.push_back(2); stringstream ss; boost::archive::binary_oarchive oa(ss); oa << ret << vc; ms.stru = ss.str(); ms.len = ss.str().size(); q_stu.push(ms); } void funb(const char* arg, int len) { std::stringstream r_ss; r_ss.write(arg, len); boost::archive::binary_iarchive ia(r_ss); q_stu.pop(); int ret; vector<int> vct; ia >> ret >> vct; } int main() { funa(); funb(q_stu.front().stru.c_str(), q_stu.front().len); getchar(); return 0; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。