Here is a little program which shows how you re-implement serialization of
std::list
#include
#include
#include
namespace boost {
namespace serialization {
// replace default serialization for lists of nvp in ALL archives
template
inline void serialize(
Archive & ar,
std::list & t,
const unsigned int version
){
// r
std::list::iterator itr =
t.begin();
while(itr != t.end()){
ar & *itr;
itr++;
}
}
// OR
// replace default serialization for lists of nvp only in xml_archives
template
inline void serialize(
boost::archive::xml_oarchive & ar,
std::list & t,
const unsigned int version
){
std::list::iterator itr =
t.begin();
while(itr != t.end()){
ar & *itr;
itr++;
}
}
template
inline void serialize(
boost::archive::xml_iarchive & ar,
std::list & t,
const unsigned int version
){
// r
std::list::iterator itr =
t.begin();
while(itr != t.end()){
ar & *itr;
itr++;
}
}
} // serialization
} // boost
main(int arg, char *argv[]){
std::ofstream os("test");
boost::archive::xml_oarchive oa(os);
const std::list l;
oa << BOOST_SERIALIZATION_NVP(l);
}