
Here is a little program which shows how you re-implement serialization of std::list<nvp<... to your taste. The code would only apply to these kinds of lists as only in this case would the template arguments match. I've included different versions depending upon whether you want to apply the change to all archives or just xml archives. I've compiled it on VC 7.1. To actually run it, it would have to be enhanced somewhat to include serialization of the item count and maybe some other functionality of the current default implementation. Robert Ramey #include <list> #include <fstream> #include <boost/serialization/nvp.hpp> #include <boost/serialization/utility.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_iarchive.hpp> namespace boost { namespace serialization { // replace default serialization for lists of nvp in ALL archives template<class Archive, class U, class Allocator> inline void serialize( Archive & ar, std::list<boost::serialization::nvp<U>, Allocator> & t, const unsigned int version ){ // r std::list<boost::serialization::nvp<U>, Allocator>::iterator itr = t.begin(); while(itr != t.end()){ ar & *itr; itr++; } } // OR // replace default serialization for lists of nvp only in xml_archives template<class U, class Allocator> inline void serialize( boost::archive::xml_oarchive & ar, std::list<boost::serialization::nvp<U>, Allocator> & t, const unsigned int version ){ std::list<boost::serialization::nvp<U>, Allocator>::iterator itr = t.begin(); while(itr != t.end()){ ar & *itr; itr++; } } template<class U, class Allocator> inline void serialize( boost::archive::xml_iarchive & ar, std::list<boost::serialization::nvp<U>, Allocator> & t, const unsigned int version ){ // r std::list<boost::serialization::nvp<U>, Allocator>::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<boost::serialization::nvp<int> > l; oa << BOOST_SERIALIZATION_NVP(l); }