On Tuesday, November 19, 2002, at 04:32 AM, Robert Ramey wrote:
Exactly, I need more than one type of archive in the same code, some of which do contain optimized functions for C-style arrays and other contiguous homgoneneous data, and others which don't. The only solution which comes to my mind is additional virtual functions for writing blocks of primitive types, which default to just calling the operator<< (>>) n times, but can be overridden by optimized functions for those archive types where optimized writes (load) are possible. Nothing else would need to be changed. What is objectionable in that approach?Date: Mon, 18 Nov 2002 08:19:28 +0100 From: Matthias Troyeroverriding the very general template definiations above for this special case would result intemplate<class T> inline boost::basic_iarchive & operator>>(boost::basic_iarchive &ar, double & x[]){ ar.read_binary(x, sizeof(x)); } template<class T> inline boost::basic_oarchive & operator<<(boost::basic_oarchive &ar, const T &t){ ar.write_binary(x, sizeof(x)); } this skips the whole serialization system and just blasts the data in/outNo, that is not what I meant. I want to optimize reading/writing of asuppose you had a header:
std::vector<double> for SOME types of archives only for which an
optimized save/load is possible. That is e.g. not for a text or XML
archive but only for binary archives. In your proposal this could only
be done by a run time type check, a dynamic_cast to a derived optimized
class and then calling a member function of that derived class. This is
much more naturally done through additional virtual function for
writing arrays of primitive data types.
matias_superfast_binary_archive.hpp
that contained:
#include <boost/serialization/archive.hpp>
template<class T>
inline boost::basic_iarchive & operator>>(boost::basic_iarchive &ar,
double & x[]){
ar.read_binary(x, sizeof(x));
}
template<class T>
inline boost::basic_oarchive & operator<<(boost::basic_oarchive &ar,
const T &t){
ar.write_binary(x, sizeof(x));
}
endof file
wouldn't that do the job? the onlything is that you couldn't include two
different kinds of archives in the same code module.
Matthias
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost