i've been reading, cross-referencing, and ultimately not finding a coherent example and answer. what i'm trying to do is pretty simple, but i'm clearly missing something. in english, i've got a class structure with two abstract bases (pure BB derives from pure AA), which i manage as a:

std::vector<AA*>

i'd like to serialize another object containing this vector. everything except this vector serializes fine, but once it gets to the vector, it throws:

terminate called after throwing an instance of 'boost::archive::archive_exception'
  what():  unregistered class - derived class not registered or exported

i've tried a few things, including explicitly registering the parent types prior to serialization, expressly declaring the base abstract classes as such with 'BOOST_SERIALIZATION_ASSUME_ABSTRACT', etc. however, i'm left with the exception at runtime.

i'd like to get this example (and solution) on the record so others can use this excellent, if a little opaque, library. once this example is square, i'll submit it to the boost serialization maintainers to include in either the FAQ or documentation as they see fit.

sample code to replicate the problem below:

/*
    g++ -Iinclude/ -Llib -lboost_serialization ~/Desktop/ser_ex.cpp -o stest
*/
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/vector.hpp>

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

namespace bser = boost::serialization;
class AA
{
public:
    virtual void foo() = 0;
    std::string name;

    template<class Archive>
    void serialize(Archive & ar, unsigned int file_version)
    {
        ar & bser::make_nvp( "Name", name );
    }
};
BOOST_SERIALIZATION_ASSUME_ABSTRACT( AA );

class BB : pub
Edit
Report