
"Jeff Flinn" <TriumphSprint2000@hotmail.com> wrote:
While the current methods for Free Functions and Splitting save/load methods are certainly understandable and work. It would be nice to be able (partial)specialize the "serialize" function base on its IO type. It would also be nice to utilize enable_if to generate different code when the serialize function is instantiated for input/output archives. This would allow compile time constructs similar to mfc's runtime Ar.IsLoad().
template<typename Archive> bool is_saving(const Archive& arch) { return boost::is_base_and_derived<boost::archive::basic_oarchive, Archive>::value; } Can be used like: template<typename Archive> void serialize(Archive & ar, const unsigned int version) { ar & value_1; ... ar & value_n if (is_saving(ar)) { ... } else { .. } ar & value_n+1; ... } /Pavel