boost serialization + boost variant + boost blank

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

boost serialization + boost variant + boost blank

Merrill Cornish
I'm running Boost 1.57.0 using serialization, variant, and boost::blank
with that variant.

I found that when compiled, serialization complains that blank does not
contain a serialize method, which is true.

I made a copy of blank.hpp, called it blank.h,  and added

     template< class Archive >
     void serialize(Archive& ar, const unsigned int version) {}

to the body of struct blank.  That made the compiler happy, but is it a
fix in general?

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost serialization + boost variant + boost blank

Andreas M. Iwanowski
Check out non-intrusive serialization:

http://www.boost.org/doc/libs/1_57_0/libs/serialization/doc/tutorial.html#nonintrusiveversion

Maybe that will work for you without modifying the class.

Mit freundlichen Grüßen / With best regards

Andreas Iwanowski - IT Administrator / Software Developer
www.awato.de | [hidden email]
T: +49 (0)2133 26031 55 | F: +49 (0)2133 26031 01
awato Software GmbH | Salm Reifferscheidt Allee 37 | D-41540 Dormagen

avisor-Support | T: +49 (0)621 6094 043 | F: +49 (0)621 6071 447

Geschäftsführer: Ursula Iwanowski | HRB: Neuss 7208 | VAT-no.: DE 122796158


-----Original Message-----
From: Boost-users [mailto:[hidden email]] On Behalf Of Merrill Cornish
Sent: Sunday, 01 February, 2015 18:41
To: [hidden email]
Subject: [Boost-users] boost serialization + boost variant + boost blank

I'm running Boost 1.57.0 using serialization, variant, and boost::blank
with that variant.

I found that when compiled, serialization complains that blank does not
contain a serialize method, which is true.

I made a copy of blank.hpp, called it blank.h,  and added

     template< class Archive >
     void serialize(Archive& ar, const unsigned int version) {}

to the body of struct blank.  That made the compiler happy, but is it a
fix in general?

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost serialization + boost variant + boost blank

Merrill Cornish
If simply defining an empty serialize() function really works, then your
suggestion is best.  Next, question, does it really work--or just
temporarily satisfy the compiler.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost serialization + boost variant + boost blank

Andreas M. Iwanowski
If you must serialize the variant then a serialize() will have to be defined for every type.

Unless I have misunderstood what you mean by "really works":
It's not about satisfying the compiler, but rather telling it how to serialize this member.
By telling it (with an empty serialize() ) to not serialize or de-serialize anything, it works appropriately, as long as you read/write the same data in the same order (i.e. nothing :) )


Mit freundlichen Grüßen / With best regards

Andreas Iwanowski - IT Administrator / Software Developer
www.awato.de | [hidden email]
T: +49 (0)2133 26031 55 | F: +49 (0)2133 26031 01
awato Software GmbH | Salm Reifferscheidt Allee 37 | D-41540 Dormagen

avisor-Support | T: +49 (0)621 6094 043 | F: +49 (0)621 6071 447

Geschäftsführer: Ursula Iwanowski | HRB: Neuss 7208 | VAT-no.: DE 122796158


-----Original Message-----
From: Boost-users [mailto:[hidden email]] On Behalf Of Merrill Cornish
Sent: Sunday, 01 February, 2015 21:16
To: [hidden email]
Subject: Re: [Boost-users] boost serialization + boost variant + boost blank

If simply defining an empty serialize() function really works, then your suggestion is best.  Next, question, does it really work--or just temporarily satisfy the compiler.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost serialization + boost variant + boost blank

Ioannis Papadopoulos-2
On 02/01/2015 02:25 PM, Andreas M. Iwanowski wrote:
> If you must serialize the variant then a serialize() will have to be defined for every type.
>
> Unless I have misunderstood what you mean by "really works":
> It's not about satisfying the compiler, but rather telling it how to serialize this member.
> By telling it (with an empty serialize() ) to not serialize or de-serialize anything, it works appropriately, as long as you read/write the same data in the same order (i.e. nothing :) )
>

Shouldn't the serialization library recognize empty classes (through
boost:is_empty) and handle those cases automatically?

>
> Mit freundlichen Grüßen / With best regards
>
> Andreas Iwanowski - IT Administrator / Software Developer
> www.awato.de | [hidden email]
> T: +49 (0)2133 26031 55 | F: +49 (0)2133 26031 01
> awato Software GmbH | Salm Reifferscheidt Allee 37 | D-41540 Dormagen
>
> avisor-Support | T: +49 (0)621 6094 043 | F: +49 (0)621 6071 447
>
> Geschäftsführer: Ursula Iwanowski | HRB: Neuss 7208 | VAT-no.: DE 122796158
>
>
> -----Original Message-----
> From: Boost-users [mailto:[hidden email]] On Behalf Of Merrill Cornish
> Sent: Sunday, 01 February, 2015 21:16
> To: [hidden email]
> Subject: Re: [Boost-users] boost serialization + boost variant + boost blank
>
> If simply defining an empty serialize() function really works, then your suggestion is best.  Next, question, does it really work--or just temporarily satisfy the compiler.
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost serialization + boost variant + boost blank

Robert Ramey
Ioannis Papadopoulos-2 wrote
Shouldn't the serialization library recognize empty classes (through
boost:is_empty) and handle those cases automatically?
serialization of an empty class is not an legal operation.

Robert Ramey
Reply | Threaded
Open this post in threaded view
|

Re: boost serialization + boost variant + boost blank

Robert Ramey
Robert Ramey wrote
Ioannis Papadopoulos-2 wrote
Shouldn't the serialization library recognize empty classes (through
boost:is_empty) and handle those cases automatically?
serialization of an empty class is not an legal operation.
Whoops - I meant to say that serialization of an empty class IS a legal operation

Robert Ramey