Re: [Boost-users] (de)serializing map<const A*>

Hi Robert, I am using VC++ 2003 I must say, the following workaround just work :) :) :) void load(Archive & ar, const unsigned int version) { void * xptr; xptr = & fiducialPairSearchRegionMap; map<FiducialPair *, vector<RectPair> > *mptr; mptr = static_cast<map<FiducialPair *, vector<RectPair> > >(xptr); ar >> *mptr; } Btw, may I know what is the reason behind of using static_cast instead of reinterpret_cast (reinterpert_cast can be compiled too)? Is it by following a thumb of rule, "use static_cast if you can and use reinterpret_cast if you have to"? Thank you very much! yccheok

Cheok Yan Cheng wrote:
Hi Robert,
I am using VC++ 2003
I must say, the following workaround just work :) :) :)
void load(Archive & ar, const unsigned int version) { void * xptr; xptr = & fiducialPairSearchRegionMap; map<FiducialPair *, vector<RectPair> > *mptr; mptr = static_cast<map<FiducialPair *, vector<RectPair> > >(xptr); ar >> *mptr; }
Btw, may I know what is the reason behind of using static_cast instead of reinterpret_cast (reinterpert_cast can be compiled too)? Is it by following a thumb of rule, "use static_cast if you can and use reinterpret_cast if you have to"?
I just used static cast because I thought we couldn't get reinterpret cast to work. (of course now I don't remember). When that failed I just "passed" the address through a void * by casting. I would hope that the compiler is smart enough to optimize all this stuff away.
Thank you very much!
You're welcome.
yccheok
participants (2)
-
Cheok Yan Cheng
-
Robert Ramey