Boost logo

Boost Users :

Subject: Re: [Boost-users] Problem serializing unsigned int via save/load
From: Robert Ramey (ramey_at_[hidden])
Date: 2008-09-16 16:10:41


> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net