serialization on const member and map<const CLASS*, CLASS>
Hi, I am trying to perform serialization on a const
member
const ImageRegion* imageRegion;
By refering to
http://www.boost.org/libs/serialization/doc/serialization.html#const,
I thought the following code would work.
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int
version)
{
ar & const_cast
To me, your code looks ok. I wonder if c:\yccheok\pcbvisionlib\FiducialPair.h(42): includes the declarations for ImageRegion. That's the onlything I can think of. Robert Ramey Cheok Yan Cheng wrote:
Hi, I am trying to perform serialization on a const member
const ImageRegion* imageRegion;
By refering to http://www.boost.org/libs/serialization/doc/serialization.html#const, I thought the following code would work.
friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & const_cast
(imageRegion); } However, I still get the following error is VC++ 2003
c:\yccheok\pcbvisionlib\FiducialPair.h(42): error C2679: binary '&' : no operator found which takes a right-hand operand of type 'ImageRegion *' (or there is no acceptable conversion)
I had fully tested the ImageRegion class. Before this const member variable, it can be fully serialized with no problem.
Any suggestion? Thank you!
p/s
By refering to the mailing list "(de)serializing vector
" http://groups.google.com/group/boost-list/browse_frm/thread/79dba906901d039f/38ac71e4da0c1b3d?lnk=gst&q=serialization+const+pointer&rnum=7#38ac71e4da0c1b3d, does it mean that boost is also not allow to (de)serialize map
directly? Must I iterate through the map elements one by one to serialize them manually? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
participants (2)
-
Cheok Yan Cheng
-
Robert Ramey