
Upon (re) reading this, I'm not really sure what is being suggested here. That's why I didn't respond to the original post. I think my view that there is no problem probably reflects my lack of understanding of the original question. Anyway - here it is. Robert Ramey
Why not make include polymorphic_archive automatic? And make other archive types resort to polymorphic_archive when no serialization for that archive type was BOOST_CLASS_EXPORTED. As you say, the only cost is a "teensy bit of execution time", in most cases users won't even notice, but the code size will be reduced.
I am generally not in favor of adding code not requested by the library user and not required. I much prefer that the library reflect what the user has said he wants. So my view is there are a couple of options. a) if one want's to use a polymorphic archive, include that in a (possibly precompiled) module. b) if one want's to use the template archive implementations, specify the ones you want. c) if this generates too much code bloat, make a library which includes any or all of the above. Its fairly easy to do this. Then link against your library of serialization implementations. Only ones actually used will be included in your program. So this would automatically give you access to ALL archive implementations without including dead code in your applications. The C++ module to build the library would look something like: #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/xml_iarchive.hpp> ... #include <boost/archive/polymorphic_iarchive.hpp> #include <boost/archive/polymorphic_oarchive.hpp> #include A.hpp #include B.hpp ... // if class modules above don't include export then BOOST_CLASS_EXPORT(A) BOOST_CLASS_EXPORT(B) Robert Ramey