
Hi Robert, I have now implemented the array wrappers and, as expected, all of my archives also work with that solution. In running the regression tests I realized that besides changing the C-array and std::vector serialization, the following changes neeed to be done to the core serialization library: 1. in archive/detail/iserializer.hpp the following change is needed: @@ -584,6 +586,10 @@ inline void load(Archive &ar, const serialization::binary_object &t){ boost::archive::load(ar, const_cast<serialization::binary_object &>(t)); } +template<class Archive, class T> +inline void load(Archive &ar, const serialization::array<T> &t){ + boost::archive::load(ar, const_cast<serialization::array<T> &>(t)); +} This is needed because the wrappers are usually passed as const arguments, and you did the same overload also for nvp and binary_object. 2. in archive/basic_xml_oarchive.hpp the following is needed: @@ -100,6 +101,20 @@ this->This()->save_end(t.name()); } + // specific overrides for arrays + // want to trap them before the above "fall through" + + template<class T> + void save_override( + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + const + #endif + ::boost::serialization::array<T> & t, + int + ){ + archive::save(* this->This(), t); + } + // specific overrides for attributes - not name value pairs so we // want to trap them before the above "fall through" BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) and in archive/basic_xml_iarchive.hpp: @@ -81,6 +82,19 @@ load_end(t.name()); } + + // specific overrides for arrays + template<class T> + void load_override( + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + const + #endif + boost::serialization::array<T> & t, + int + ){ + archive::load(* this->This(), t); + } + // specific overrides for attributes - handle as // primitives. These are not name-value pairs // so they have to be intercepted here and passed on to load. to allow the array wrapper to be serialized although it is not a nvp. Note that we cannot just put the array wrapper into an nvp since that opuld break compatibility with the old XML archive format. These changes are in addition to changing the C-array and std::vector serialization. My question to you is whether in light of this additional intrusion into the unrelated XML archives you still prefer this solution over the save_array/load_array free functions proposed by Dave? If you do then I can send you my implementation. Also, when you find time, could you please answer to my mail of a few days ago regarding the issues in std::vector serialization. Matthias