Date: 2004-05-04 09:59:47
Even though the formal review is already over, I would like to make a
couple of remarks regarding boost::serialization. First of all I like the
design of the library and I'm glad it got accepted into Boost. We've
started using the library about two weeks ago, at first only for
serializing simple configuration data. But now we're looking into the
possibility of using it fully as our serialization mechanism.
Our project is rather large and it uses shared_ptrs extensively.
Therefore, proper support for shared_ptr is very important to us.
Unfortunately, the way shared_ptr is serialized currently is not really
optimal, as has been discussed on this list before. Also weak_ptr is not
yet supported, which is also a requirement for us. Apart from that, the
fact that the macro BOOST_SHARED_POINTER_EXPORT has to be used to register
the boost::detail::sp-counted_base_impl type is not very nice.
Is there work under way to improve the serialization of
shared_ptr/weak_ptr? Some kind of generic mechanism to serialize other
smart pointer types, such as boost::shared_array or boost::intrusive_ptr,
would be very nice.
Our system consists of a number of DLLs and we need boost::serialization
to be built as DLL as well. I quickly hacked a number of
__declspec(dllexport) declarations into the source and created a DLL
project with MSVC 7.1 and everything seemed to work fine at first.
However, there are problems because of the fact that some of the template
classes use static variables that are defined in header files. When
included from multiple DLLs, this will cause multiple instances of that
static variable to exist, one each for each DLL, although there should
only be one instance for the entire program. Thus, if an attempt is made
to serialize an object that belongs to one DLL from another DLL all sorts
of things go wrong.
For example, two template classes in boost::serialization that cause these
problems are extended_type_info_no_rtti and extended_type_info_rtti, which
declare static local variables in a function called get_instance in their
respective header files. Also the static_initializer template class in
void_cast.hpp defines a static member variable. I might have missed some
Is there work under way to fix this and have working DLL builds of
boost::serialization (just as there are DLL builds for, say,
In the documentation I would like to see a remark in the section on Export
Keys, i.e. the BOOST_CLASS_EXPORT macro, that the export macros must not
be used in header files, at least not in header files included by multiple
clients, because they implement global variables that must exist only
One thing I also find unfortunate is that the BOOST_CLASS_EXPORT macro has
to be used at global scope and cannot be used inside namespaces. Is there
a way to fix this? The same goes for BOOST_SERIALIZATION_SPLIT_FREE.
On MSVC 7.1 serialization of a std::vector<bool> doesn't work with the
default implementation of the boost::serialization library. The compiler
complains in save_collection in the line
save_construct_data(ar, &(*it), 0U);
with the error
C2101: '&' requires l-value
I presume this is because dereferencing an iterator to a std::vector<bool>
returns a proxy object. A simple solution to this is to specialize the
serialize free function for std::vector<bool>.
Industrie- und Unterhaltungselektronik GmbH & CoKG
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk