
On Thu, Jul 29, 2010 at 12:20 PM, Robert Ramey
Robert Bigaignon wrote:
Hi all,
I'm having trouble with Boost's serialization library that I'm trying to integrate with an existing class hierarchy that used MFC toolkit as the archiver.
It seems that when a serializable class defines a specialized save (or load or serialize for that matter) in addition to the generic method, the serialization library gets confused and ends up not identify properly that the hierarchy of serializable classes uses multiple inheritance and in particular diamond-shaped inheritance.
I've reproduced the problem using the test_diamond code example provided with Boost 1.43 using MS VC 9.0 by adding a save method specialized for archive::text_oarchive to the derived1 class defined in test_diamond.cpp. The following diff shows the implementation of this specialized method:
Without looking at this particular case, I would note that 1.44 - next release contains changes and a new test test_diamond_complex which improves support in this situation.
Robert Ramey
Hi list, Robert, A colleague of mine tried to compile my code with GCC, and it turned out that the C++ I wrote is not legal. The explicit template specialization was not in the correct namespace. The standard says:
An explicit specialization shall be declared in the namespace of which the template is a member, or, for member templates, in the namespace of which the enclosing class or enclosing class template is a member. An explicit specialization of a member function, member class or static data member of a class template shall be declared in the namespace of which the class template is a member
So it seems that my issue comes from the compiler, which did not warn me about writting illegal C++ and, as a result, ended up with some crippled executable. -- Robert Bigaignon