| 1 | 
 | 
|---|
| 2 | #include <boost/archive/polymorphic_text_oarchive.hpp>
 | 
|---|
| 3 | #include <boost/serialization/serialization.hpp>
 | 
|---|
| 4 | #include <sstream>
 | 
|---|
| 5 | 
 | 
|---|
| 6 | using namespace boost;
 | 
|---|
| 7 | 
 | 
|---|
| 8 | struct B
 | 
|---|
| 9 | {
 | 
|---|
| 10 |     virtual ~B()
 | 
|---|
| 11 |     {}
 | 
|---|
| 12 | 
 | 
|---|
| 13 |     template <typename A>
 | 
|---|
| 14 |     void serialize(A &, const unsigned)
 | 
|---|
| 15 |     {}
 | 
|---|
| 16 | };
 | 
|---|
| 17 | 
 | 
|---|
| 18 | struct D : B
 | 
|---|
| 19 | {
 | 
|---|
| 20 |     template <typename A>
 | 
|---|
| 21 |     void serialize(A &a, const unsigned)
 | 
|---|
| 22 |     {
 | 
|---|
| 23 |         a & serialization::base_object<B>(*this);
 | 
|---|
| 24 |     }
 | 
|---|
| 25 | };
 | 
|---|
| 26 | 
 | 
|---|
| 27 | void
 | 
|---|
| 28 | register_type_ambig()
 | 
|---|
| 29 | {
 | 
|---|
| 30 |     B *bp = new D;
 | 
|---|
| 31 | 
 | 
|---|
| 32 |     std::ostringstream ostr;
 | 
|---|
| 33 |     archive::polymorphic_text_oarchive oa(ostr);
 | 
|---|
| 34 |     oa.register_type<D>();
 | 
|---|
| 35 |     oa & bp;
 | 
|---|
| 36 | 
 | 
|---|
| 37 |     delete bp;
 | 
|---|
| 38 | }
 | 
|---|