Problem serializing unsigned int via save/load
Is there a trick or known bug with serializing an unsigned int via the split free functions? I have a structure that contains an unsigned int, and if I serialize with the free serialize function it works as it should. However, if I split the serialization into save/load I get: boost_1_36_0/boost/archive/detail/iserializer.hpp:541: error: conversion from `boost::serialization::is_wrapper<unsigned int>' to non-scalar type `mpl_::bool_< true>' requested Here's my structure and the two pieces of serialization code: typedef struct CCSTRUCT { unsigned int numRtp; } CCSTRUCT; Serialization #1 (works): template<class Archive> void serialize(Archive & ar, CCSTRUCT& it, const unsigned int version) { ar & it.numRtp; } Serialization #2 (doesn't work): BOOST_SERIALIZATION_SPLIT_FREE(CCSTRUCT) template<class Archive> void save(Archive & ar, const CCSTRUCT& d, unsigned int /* version */) { ar << d.numRtp; } template<class Archive> void load(Archive & ar, const CCSTRUCT& d, unsigned int /* version */) { ar >> d.numRtp; } I need to split the serialization because there are other elements in the structure that can't be handled in serialize(), so I would really appreciate some help if anyone has any ideas. Thanks, Diane
template<class Archive> void load(Archive & ar, const CCSTRUCT& d, /* remove const here !!! */ unsigned int /* version */) { ar >> d.numRtp; }
Robert Ramey Diane wrote:
Is there a trick or known bug with serializing an unsigned int via the split free functions? I have a structure that contains an unsigned int, and if I serialize with the free serialize function it works as it should. However, if I split the serialization into save/load I get:
boost_1_36_0/boost/archive/detail/iserializer.hpp:541: error: conversion from `boost::serialization::is_wrapper<unsigned int>' to non-scalar type `mpl_::bool_< true>' requested
Here's my structure and the two pieces of serialization code:
typedef struct CCSTRUCT { unsigned int numRtp; } CCSTRUCT;
Serialization #1 (works):
template<class Archive> void serialize(Archive & ar, CCSTRUCT& it, const unsigned int version) { ar & it.numRtp; }
Serialization #2 (doesn't work):
BOOST_SERIALIZATION_SPLIT_FREE(CCSTRUCT)
template<class Archive> void save(Archive & ar, const CCSTRUCT& d, unsigned int /* version */) { ar << d.numRtp; }
template<class Archive> void load(Archive & ar, const CCSTRUCT& d, unsigned int /* version */) { ar >> d.numRtp; }
I need to split the serialization because there are other elements in the structure that can't be handled in serialize(), so I would really appreciate some help if anyone has any ideas.
Thanks, Diane
participants (2)
-
Diane
-
Robert Ramey