Well, the problem is quite obvious: <>
don't go well inside XML element tags.
So, here's what you I naively thought of to fix it.
ar & boost::serialization::make_nvp(
"base", static_cast<classOne<T>&>(*this));
IMPORTANT UPDATE However, just today, I stumbled across the documentation here:
Note the serialization of the base classes from the derived class. Do NOT directly call the base class serialize functions. Doing so might seem to work but will bypass the code that tracks instances written to storage to eliminate redundancies. It will also bypass the writing of class version information into the archive. For this reason, it is advisable to always make member serialize functions private.
Oops. So here's the new and correct advice:
typedef classOne<T> baseClass;
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(baseClass);
Now, you control the name of the xml element by working with the macro and using a typedef to hide the brackets.
Output:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="10">
<ch2 class_id="0" tracking_level="0" version="0">
<baseClass class_id="1" tracking_level="0" version="0">
<st>0.5</st>
</baseClass>
<error>0.5</error>
</ch2>