c++ - How does boost::serialization Archive::register_type work? -


boost::serialization able serialize polymorphic objects of most-derived class if these objects pointed reference/pointer base class. without needing virtual functions.

to able that, boost::serialization requires know existent polymorphic types: archive::register_type must called on archive object used serialize.

this example shows how register types , how serialize them.


i'm wondering how achieved.
tried @ boost::serialization source code failed: i'm not template metaprogramming.

boost.serialization can write out polymorphic class using either typeid() or user defined function get_key returns actual type of polymorphic object.

register_type works using type supplied instantiate template allows archive map type identifier (either typeid(t) or result of t::get_key()) object knows how serialize t.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -