Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9843: binary serializer wrong behaviour treating enums
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-14 05:59:39
#9843: binary serializer wrong behaviour treating enums
-------------------------------+-----------------------------------------
Reporter: jpjps@⦠| Owner: ramey
Type: Bugs | Status: reopened
Milestone: To Be Determined | Component: serialization
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords: enum seriliazation typesize
-------------------------------+-----------------------------------------
Comment (by ramey):
OK - I see the problem now.
{{{
// works
enum class PacketCode {
Something,
};
// doesn't work
enum class PacketCode : unsigned char
{
Something,
};
}}}
But I can't see where the problem is since the load and save functions
both confer to/from integers the serialization should be in sync. Your
original complaint says that it's saving one byte and reading back 4. The
file oserializer.hpp contains:
{{{
template<class Archive>
struct save_enum_type
{
template<class T>
static void invoke(Archive &ar, const T &t){
// convert enum to integers on save
const int i = static_cast<int>(t);
ar << boost::serialization::make_nvp(NULL, i);
}
};
}}}
I'm guessing I did this because the streams didn't accept an enum. If you
would like, you can make a test case similar to the ones in the test suite
and submit a patch. I'd be willing to consider it.
Robert Ramey
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9843#comment:8> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC