As part of upgrading a product to a later version of boost the compilation has tripped up on serialization of a boost::optionalstd::string. The /optional.hpp/ header now has the comment: ...and this fires for std::string. What, if any, is the recommended way forward for this? An example code snippet to illustrate: Previous version of boost: 1.50; new: 1.6x Compiling with g++ 4.6.4 (although same problem with 4.8.5): -W -Wall -std=c++0x... (The real code is actually using the portable_binary_archive, but let's avoid muddying the waters at this stage :) -- Sent from: http://boost.2283326.n4.nabble.com/Boost-Users-f2553780.html
OK, so it looks like posting from nabble loses the raw-tag stuff...
The optional.hpp comment:
// It is an inherent limitation to the serialization of optional.hpp
// that the underlying type must be either a pointer or must have a
// default constructor. It's possible that this could change sometime
// in the future, but for now, one will have to work around it. This
can
// be done by serialization the optional<T> as optional
On 2/19/18 4:35 AM, Chardrazle via Boost-users wrote:
As part of upgrading a product to a later version of boost the compilation has tripped up on serialization of a boost::optionalstd::string.
The /optional.hpp/ header now has the comment:
...and this fires for std::string.
What, if any, is the recommended way forward for this?
Hmmm- is std::string not default constructible?
Indeed, and my initial workaround was to force that through:
It may be related to: https://svn.boost.org/trac10/ticket/13108
(is_default_constructible support.)
Time to start muddying the waters.
(Note: the binary archives were taken from the latest serialization 'test'
code area.)
Some test code:
#include
On 2/20/18 1:41 AM, Chardrazle via Boost-users wrote:
Indeed, and my initial workaround was to force that through:
It may be related to: https://svn.boost.org/trac10/ticket/13108 (is_default_constructible support.)
Time to start muddying the waters. (Note: the binary archives were taken from the latest serialization 'test' code area.)
Your on the right track here. Note that the boost regression tests http://www.boost.org/development/tests/develop/developer/serialization.html show serialization of optional passing with all archives - including the binary one. So it seems that this is an issue related to portable_binary_archive which has the status and example not being currently being tested on a regular basis. In theory, the code in archive implementations should be totally agnostic to the data type being serialized. Alas, s*** happens. I would recommend tracing with the debugger trough serialization of optional<string> in portable binary archive to see how it's different from serialization in binary or text archive. I've been wanting to promote portable_binary_archive to "offically supported" status, but I can't justify spending the time. Robert Ramey
I've been wanting to promote portable_binary_archive to "offically supported" status, but I can't justify spending the time.
This is why I thought I'd better post here, rather than going straight to trac :) I'm glad I did. I performed some further investigation by trying the sample code on my home set-up, with variations of g++ versions. I found no problems whatsoever with the portable_binary_archive. I suspect that whatever configuration has been used at the company has really messed up something to do with memory management. -- Sent from: http://boost.2283326.n4.nabble.com/Boost-Users-f2553780.html
I would recommend tracing with the debugger trough serialization of optional<string> in portable binary archive to see how it's different from serialization in binary or text archive.
I've performed a bit more analysis and it looks like serialization of
optional<> with any non-trivial types is broken in 1.64.
The serialization/optional.hpp load function:
template
participants (2)
-
Chardrazle
-
Robert Ramey