
This is my concern as well. I am interested in addressing this in a definitive way. But its not trivial to do a good job which can be proven to work while at the same time not adding a performance hit to every user of the package. Robert Ramey Sergey Skorniakov wrote:
Thank you for your answer. My application is mono thread and duplicated code for seralization is granted to be the same. Our code actually forbide this design. What about replacing line 74&75 of
extended_type_info.cpp : 74 assert(lookup(eti) == m_self->m_map.end()); 75 m_self->m_map.insert(eti);
by
if ( lookup(eti) == m_self->m_map.end() ) { m_self->m_map.insert(eti); }
? With this new behavior the same type_info can be registred several time.
With this modification my design work fine. I can send you a sample of code if you want to investigate the problem
This modification will just leads to hard-to-find bugs. Take a look how this information is used in the library - for example, void_caster_compare uses extended_type_info::operator< and it will works wrong (results will be similar as derived class is not registered), because same type infos will be treated as different. Comparison of extended_type_info are also used in basic_archive_impl::helper_compare, in basic_serializer::operator< and may be in some other places. Thus, to support multiple registration, you should provide such extended_type_info::operator< implementation that duplicated type infos from different libs will be equivalent. I had just added double-linked list of extended_type_info to extended_type_info and adds duplicated type infos to the tail of this list. For operator< i mplemented as comparison of lists heads (first registered type info). Also, modification of basic_serializer::operator< required because it compares addresses of type infos instead of using extended_type_info::operator<.