#include /* keep it first to prevent nasty warns in MSVC */ #include #include #include #include #include #include #include #include #include #include using namespace boost::multi_index; typedef multi_index_container< int, indexed_by< ordered_non_unique >, ordered_non_unique,std::greater >, sequenced<> > > multi_t; template void poor_man_multi_index_save(Archive& ar,const MultiIndexContainer& m) { const typename MultiIndexContainer::size_type s=m.size(); ar< void poor_man_multi_index_load(Archive& ar,MultiIndexContainer& m) { typename MultiIndexContainer::size_type s; ar>>s; while(s--){ typename MultiIndexContainer::value_type x; ar>>x; m.insert(m.end(),x); } } int main() { multi_t m1; for(int i=0;i<100;++i)m1.insert(i); std::ostringstream oss; { boost::archive::text_oarchive oa(oss); poor_man_multi_index_save(oa,m1); } multi_t m2; std::istringstream iss(oss.str()); boost::archive::text_iarchive ia(iss); poor_man_multi_index_load(ia,m2); assert(std::equal(m1.begin(),m1.end(),m2.begin())); }