[serialization] Issues with/questions about polymorphic archives
I'm seeing the following error when trying to serialize from a polymorphic_iarchive. I'm new to boost::serialization, so I was hoping somebody could shed some light on what I was doing wrong? I tried googling and searching the archives, but didn't find anything yet. error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'const boost::archive::polymorphic_iarchive' (or there is no acceptable conversion) c:\boost\include\boost-1_35\boost\archive\detail\interface_iarchive.hpp(62): could be 'Archive &boost::archive::detail::interface_iarchive<Archive>::operator >><const boost::serialization::nvp<T>>(const boost::serialization::nvp<T> &)' The code in question is essentially: virtual void foo(const boost::archive::polymorphic_iarchive& ar) { ar >> boost::serialization::make_nvp("typeName", *typePtr); ... } Also, it appears as though get_library_version() is private for polymorphic_iarchive_dispatch. I'm confused, isn't it public elsewhere? I was hoping to have access to it. I reckon there's a reason behind this, so I'm just curious as to why it's private. Thanks!
An archive can't be const as it is changed when something is serialized to it try: void foo(boost::archive::polymorphic_iarchive& ar) { ar >> boost::serialization::make_nvp("typeName", *typePtr); ... } Robert Ramey Anis wrote:
I'm seeing the following error when trying to serialize from a polymorphic_iarchive. I'm new to boost::serialization, so I was hoping somebody could shed some light on what I was doing wrong? I tried googling and searching the archives, but didn't find anything yet.
error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'const boost::archive::polymorphic_iarchive' (or there is no acceptable conversion) c:\boost\include\boost-1_35\boost\archive\detail\interface_iarchive.hpp(62): could be 'Archive &boost::archive::detail::interface_iarchive<Archive>::operator
<const boost::serialization::nvp<T>>(const boost::serialization::nvp<T> &)'
The code in question is essentially: virtual void foo(const boost::archive::polymorphic_iarchive& ar) { ar >> boost::serialization::make_nvp("typeName", *typePtr); ... }
Also, it appears as though get_library_version() is private for polymorphic_iarchive_dispatch. I'm confused, isn't it public elsewhere? I was hoping to have access to it. I reckon there's a reason behind this, so I'm just curious as to why it's private.
Thanks!
Thanks for the prompt reply. Yes, that was it. I forgot that internal state inside the archive may be changing after serialization. What about the private nature of get_library_version()? I can't invoke the method on a polymorphic_binary_iarchive because it's private, whereas it's public in a binary_archive. This isn't a big issue, I can certainly work around it, it's more of a personal curiosity. Thanks again, Anis "Robert Ramey" <ramey@rrsd.com> wrote in message news:g14420$86p$1@ger.gmane.org...
An archive can't be const as it is changed when something is serialized to it
try:
void foo(boost::archive::polymorphic_iarchive& ar) { ar >> boost::serialization::make_nvp("typeName", *typePtr); ... }
Robert Ramey
Anis wrote:
I'm seeing the following error when trying to serialize from a polymorphic_iarchive. I'm new to boost::serialization, so I was hoping somebody could shed some light on what I was doing wrong? I tried googling and searching the archives, but didn't find anything yet.
error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'const boost::archive::polymorphic_iarchive' (or there is no acceptable conversion) c:\boost\include\boost-1_35\boost\archive\detail\interface_iarchive.hpp(62): could be 'Archive &boost::archive::detail::interface_iarchive<Archive>::operator
<const boost::serialization::nvp<T>>(const boost::serialization::nvp<T> &)'
The code in question is essentially: virtual void foo(const boost::archive::polymorphic_iarchive& ar) { ar >> boost::serialization::make_nvp("typeName", *typePtr); ... }
Also, it appears as though get_library_version() is private for polymorphic_iarchive_dispatch. I'm confused, isn't it public elsewhere? I was hoping to have access to it. I reckon there's a reason behind this, so I'm just curious as to why it's private.
Thanks!
"Anis" <mighty_ernie@hotmail.com> wrote in message news:g145sq$fg7$1@ger.gmane.org...
Thanks for the prompt reply. Yes, that was it. I forgot that internal state inside the archive may be changing after serialization.
What about the private nature of get_library_version()? I can't invoke the method on a polymorphic_binary_iarchive because it's private, whereas it's public in a binary_archive. This isn't a big issue, I can certainly work around it, it's more of a personal curiosity.
Looks like an oversight to me. The all archives should have the same interface. Open a Trak Ticket for this. Robert Ramey
participants (2)
-
Anis
-
Robert Ramey