Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Serializing a reference
From: Ben (midfield_at_[hidden])
Date: 2009-10-28 20:11:54


> From: Steven Watanabe <watanabesj_at_[hidden]>
>
> Ben wrote:
>> template<class Ar>
>> void save_construct_data(Ar & ar, const B * b, const unsigned int ver) {
>>   ar << (&(b->a));
>> }
>>
>> <snip>
>
> You're trying to serialize an rvalue.

thanks for pointing out my error. how do i get around it? i am not a
C++ expert but how do i serialize the reference as a pointer? i tried
various castings to no avail. by the way, what i wrote was copied
nearly verbatim from the documentation

template<class Archive>
inline void save_construct_data(
    Archive & ar, const my_class * t, const unsigned int file_version
){
    // save data required to construct instance
    ar << t.member1;
    // serialize reference to object as a pointer
    ar << & t.member2;
}

which seems like it wouldn't compile, since t is a pointer so
t.member2 doesn't seem right.

thanks, and best regards,
ben


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