I haven't actually happened upon this problem yet but I just want to
know if I know how to deal with it for the future.
My question is: how does the serialization work (or not work) if we add
or remove indexes from the type?
My suspicion is that one would have to do something like this:
// version 1:
BOOST_CLASS_VERSION(Thingy,1);
typedef multi_index_container myset1_t;
myset1_t m_MySet;
...
template<typename Ar>
void serialize(Ar & a, unsigned int)
{ ar & m_MySet; }
// version 2
BOOST_CLASS_VERSION(Thingy,2);
typedef multi_index_container myset1_t;
typedef multi_index_container myset2_t;
myset2_t m_MySet; // using new version
...
template<typename Ar>
void serialize(Ar & a, unsigned int fv)
{
if(Ar::is_loading && fv == 1)
{
myset1_t set;
ar & set;
m_MySet.clear();
m_MySet.insert(m_MySet.begin(),set.begin(),set.end());
}
else
ar & m_MySet;
}
Would this be OK, errors in syntax aside?
Thanks,
Sohail