[serialization] get rid from rtti
Folks, I have class some class Circle which is derived from Shape class. I want to get rid from RTTI. In order that I did following: BOOST_CLASS_TYPE_INFO( Circle, extended_type_info_no_rtti<Circle> ) BOOST_CLASS_EXPORT(Circle) const char * Circle::get_key() const { const boost::serialization::extended_type_info *eti = boost::serialization::type_info_implementation<Circle> ::type::get_instance(); return eti->get_key(); } But even after that, if I try to compile project a lot of waring appear: warning C4541: 'dynamic_cast' used on polymorphic type 'boost::archive::detail::basic_oarchive' with /GR-; unpredictable behavior may result it also fails with exception during runtime. What also need to be done to completely get rid form RTTI
I looked into this some.
the code for Circle looks good to me and should work.
Note that the error is with casting 'boost::archive::detail::basic_oarchive'
rather than you Circle type.
in smart_cast.hpp I find
static T cast(U & u){
// if we're in debug mode
#if ! defined(NDEBUG) \
|| defined(__BORLANDC__) && (__BORLANDC__ <= 0x560) \
|| defined(__MWERKS__)
// do a checked dynamic cast
return cross::cast(u);
#else
which looks to me that it always does a dynamic cast in debug mode.
I don't know why I did this - but you might experiment with changes here.
Note that the polymorphic archives as currently implemented will require a
dynamic_cast
on the archive class.
I believe that using the serialization library without RTTI should be
possible
but In never assembled a subset of the tests to really check it. I did I
did make
on test to verify the interoperability for different type info systems but I
left it at that.
Robert Ramey
"Yan Drugalya"
participants (2)
-
Robert Ramey
-
Yan Drugalya