Hi again, i did some research and now i am close to the conclusion that there is probably no way to fix this as there is not something like a global registry and i thus need a virtual call. However, I did a quick check of the boost/archive/polymorphic_*_iarchive issue to find out why it is broken and whether i can apply a quick fix for my users. First of all I refer to an older bug report explaining the problem: http://lists.boost.org/boost-users/2014/08/82735.php with the answer: http://lists.boost.org/boost-users/2014/08/82741.php taking a look at the trac ticket in the answer: https://svn.boost.org/trac/boost/ticket/10348 i came to the conclusion that this is not the same bug. the ticket there reported an error due to missing includes. However, the bug in the polymorphic archives is different as the polymorphic_iarchive class does not derive from detail::helper_collection (however the polymorphic_*_iarchive class do as they derive from *_iarchive via polymorphic_iarchive_rout) and thus a call to ar.template get_helper<T>() will fail when ar is the polymorphic_iarchive class. I am not sure how to fix this easily. i don't know how to access the development branch therefore i can not test whether this issue may already be fixed in development. Best, Oswin On 30.09.2014 11:55, oswin krause wrote:
Hi list,
i am currently trying to serialize a type-erasure, but i am not sure how this should be done exactly. Before boost 1.56 we used the polymorphic archives and a base class to implement serialization, but since they are broken in 1.56 and a few users are nagging me (plus i can't compile the library myself any more after a mandatory upgrade...), i have to get it right.
my setup looks like this
class ErasureBase{ .... };
template<class T> class Erasure{ public: Erasure (T& foo):m_foo(foo){} template<class Archive> void serialize(Archive & ar, const unsigned int){ ar & m_foo; } private: T& m_foo; };
class MyClass{ public: template<class T> MyClass(T& foo):m_wrapper(new Erasure<T>(foo)){} template<class Archive> void serialize(Archive & ar, const unsigned int){ ar & *m_wrapper; } private: boost::scoped_ptr<ErasureBase> m_wrapper;
};
in the usage of MyClass i assume that serialisation/deserialisation is only to be called on constructed objects of type MyClass, therefore i do not need capabilities to deserialize from pointers. The question is: how do I tell the archive which Erasure<T> exist? The solutions in the tutorial pages only look at the cases where Erasure<T> is serialized directly or where it is known which classes are to be serialized (and i don't assume my users to know which Erasure<T> are instantiated...).
If there exists a solution for this: is the solution also stable wrt the order of registration of classes?
Best, Oswin
The ques