Boost logo

Boost Users :

From: Sigurd Saue (ssaue_at_[hidden])
Date: 2006-04-04 03:41:43


We've started to use boost serialization and I've run into problems with
serialization of derived classes. The "funny" thing is that this happens
only on 64-bit Windows release compiled with MS Visual 2005. The same code
works fine on Linux 32/64 bit debug/release, on Windows 32-bit debug/release
and on Windows 64-bit debug. But not Windows 64-bit release. We use boost
version 1.33.1.

Here's the code that causes problems (Parameter is the base class,
ParamCollection is a vector of Parameters):

    template<class Archive>
    static void serialize(Archive & ar, ParamCollection & col, const
unsigned int /*version*/)
    {
      ar.register_type(static_cast<FloatParameter*>(NULL));
      ar.register_type(static_cast<IntParameter*>(NULL));
      ar.register_type(static_cast<ChoiceParameter*>(NULL));
      ar.register_type(static_cast<StringParameter*>(NULL));
      ar.register_type(static_cast<BlobParameter*>(NULL));

      ar & boost::serialization::base_object<std::vector<Parameter*> >(col);
    }

When serializing the ParamCollection (serializing, not deserializing) an
archive exception is thrown: unregistered class. I've tried to use both
abstract and non-abstract base class without any success. I did some
research in the boost code and found that the exception was thrown in
polymorphic::save (oserializer.hpp) by the last condition (NULL ==
bpos_ptr).

Any clues? Is there a workaround?

Thanks,
Sigurd


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net