Serialization - no & operator for primitives
I'm using a recent (a few days old) cvs version of boost, and
the serialization libraries, and Visual Studio 7.1 is producing the
error below. This is only happening to classes which I am exporting
(like BOOST_CLASS_EXPORT_GUID(D2::Message,"D2::Message");). The reason I
am exporting them is that they are in many cases a) subclasses of each
other b) accessed through a pointer. Any help would be deeply
appreciated.
My code is:
template<class Archive >
static void serialize(Archive & ar, D2::Message& g, const unsigned
int version)
{
ar & g.getType(); // an int - error complains about this line.
ar & g.getSender(); // a string
ar & g.getMessage(); // a string
}
Error message:
c:\D2\API\NewClient\EnhancedMessageHandler.h(132) : error C2679: binary
'&' : no operator found which takes a right-hand operand of type
'uint32' (or there is no acceptable conversion)
C:\boost\boost-cvs-20050606\boost\boost\serialization\serialization.hpp(
140) : see reference to function template instantiation 'void
boost::serialization::serialize<Archive>(Archive &,D2::Message &,const
unsigned int)' being compiled
with
[
Archive=boost::archive::detail::export_impl::for_each_archive
Marcin Tustin wrote:
template<class Archive > static void serialize(Archive & ar, D2::Message& g, const unsigned int version) { ar & g.getType(); // an int - error complains about this line.
c:\D2\API\NewClient\EnhancedMessageHandler.h(132) : error C2679: binary '&' : no operator found which takes a right-hand operand of type 'uint32' (or there is no acceptable conversion)
What is the return type of getType()? If it's 'uint32' per the error message, and the Archive type is '*_oarchive', your attempting to assign a value to a temporary rvalue(terminology?). If it did compile, I doubt it would perform as your expecting. Jeff Flinn _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ --------------------------------------------------------
Jeff Flinn
What is the return type of getType()? If it's 'uint32' per the error message, and the Archive type is '*_oarchive', your attempting to assign a value to a temporary rvalue(terminology?). If it did compile, I doubt it would perform as your expecting.
Initially, I didn't understand your point until I realised that my code is fantastically stupid. Am I being stupid in thinking that you mean '*_iarchive'? Or am I even more confused than I realise.
Marcin Tustin wrote:
Jeff Flinn
writes: What is the return type of getType()? If it's 'uint32' per the error message, and the Archive type is '*_oarchive', your attempting to assign a value to a temporary rvalue(terminology?). If it did compile, I doubt it would perform as your expecting.
Initially, I didn't understand your point until I realised that my code is fantastically stupid. Am I being stupid in thinking that you mean '*_iarchive'? Or am I even more confused than I realise.
Oops, I was thinking iarchive, but that's not what came out of my fingertips. Sorry for the (further) confusion. Jeff Flinn
participants (2)
-
Jeff Flinn
-
Marcin Tustin