This is explained in the documentation and illustrated by the demos and tests.
 
In fact, you can even build a progam which will be able to de-serialize types included
in DLLS which have yet to be created.
 
Robert Ramey
"Ryan Fowler" <Ryan.Fowler@thomsonreuters.com> wrote in message news:1C50BA0DCB34A24E9C8ABA96570EF18F073F5211@LONSMSXM06.emea.ime.reuters.com...

Hi,

 

How can I read in a from a stream when I don’t know the exact type I will be getting?  All objects I receive will derive from the same base class, but I won’t know when I receive the stream what the derived type will be and therefore I can’t create it in advance (like in the docs).

 

class base

{

}

 

class derived1 : public base

{

}

 

class derived2 : public base

{

}

 

int main()

{

    // Get a stream from somewhere

    boost::archive::binary_iarchive ia( instream );

 

    base b0;

    derived1 d1;

    derived2 d2;

    is >> // derived1 or derived2???

}

 

Ryan Fowler
Software Engineer

Thomson Reuters

Phone: +442075427063

ryan.fowler@thomsonreuters.com
thomsonreuters.com


This email was sent to you by Thomson Reuters, the global news and information company.
Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users