Last active
August 29, 2015 14:06
-
-
Save chadaustin/62db729bc13952fc47a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/serialization/base_object.hpp> | |
#include <boost/archive/text_oarchive.hpp> | |
#include <boost/serialization/export.hpp> | |
struct base { | |
virtual ~base() {} | |
template<class Archive> | |
void serialize(Archive & ar, const unsigned int version) { | |
} | |
}; | |
struct derived : base { | |
template<class Archive> | |
void serialize(Archive & ar, const unsigned int version) { | |
ar & boost::serialization::base_object<base>(*this); | |
} | |
}; | |
BOOST_CLASS_EXPORT_GUID(derived, "derived") | |
int main() { | |
base* b = new derived; | |
boost::archive::text_oarchive oa(std::cout); | |
oa & b; | |
} | |
// prints | |
// 22 serialization::archive 10 1 7 derived 1 0 | |
// 0 1 0 | |
// 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment