[serialization] class template with virtual base

Hi, I've been searching the archives but am not finding an answer... Is there any way to serialise D<> via a pointer to its base B when the types used to parameterise D<> are not known in advance? i.e. How do I register D<> with the serialisation library? For Example... struct B{ virtual void fn() =0; }; template<typename T> struct D : B{ virtual void fn(){}; }; B* b = new D<char>(); .... anArchive & b; Thanks, Richard.

This works just fine. The only problem is that the boost export macro doesn't work so you have instanciate the underlying code explicitly. Robert Ramey Richard Crossley wrote:
Hi,
I've been searching the archives but am not finding an answer... Is there any way to serialise D<> via a pointer to its base B when the types used to parameterise D<> are not known in advance? i.e. How do I register D<> with the serialisation library?
For Example...
struct B{ virtual void fn() =0; };
template<typename T> struct D : B{ virtual void fn(){}; };
B* b = new D<char>(); .... anArchive & b;
Thanks,
Richard.

Thanks, but how? Regards, Richard.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: 27 February 2008 03:47 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] class template with virtual base
This works just fine.
The only problem is that the boost export macro doesn't work so you have instanciate the underlying code explicitly.
Robert Ramey
Richard Crossley wrote:
Hi,
I've been searching the archives but am not finding an answer... Is there any way to serialise D<> via a pointer to its base B when the types used to parameterise D<> are not known in advance? i.e. How do I register D<> with the serialisation library?
For Example...
struct B{ virtual void fn() =0; };
template<typename T> struct D : B{ virtual void fn(){}; };
B* b = new D<char>(); .... anArchive & b;
Thanks,
Richard.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Look at the definition of BOOST_CLASS_EXPORT Robert Ramey Richard Crossley wrote:
Thanks, but how?
Regards,
Richard.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: 27 February 2008 03:47 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] class template with virtual base
This works just fine.
The only problem is that the boost export macro doesn't work so you have instanciate the underlying code explicitly.
Robert Ramey
Richard Crossley wrote:
Hi,
I've been searching the archives but am not finding an answer... Is there any way to serialise D<> via a pointer to its base B when the types used to parameterise D<> are not known in advance? i.e. How do I register D<> with the serialisation library?
For Example...
struct B{ virtual void fn() =0; };
template<typename T> struct D : B{ virtual void fn(){}; };
B* b = new D<char>(); .... anArchive & b;
Thanks,
Richard.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Richard Crossley
-
Robert Ramey