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<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,IplJrsMediaTimePoint>::tail,IplJrsMediaTimePoint>: :head ] C:\boost\boost-cvs-20050606\boost\boost\archive\detail\iserializer.hpp(1 61) : see reference to function template instantiation 'void boost::serialization::serialize_adl<Archive,T>(Archive &,T &,const unsigned int)' being compiled with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,IplJrsMediaTimePoint>::tail,IplJrsMediaTimePoint>: :head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\extended_type_info _typeid.hpp(71) : while compiling class-template member function 'void boost::archive::detail::iserializer<Archive,T>::load_object_data(boost:: archive::detail::basic_iarchive &,void *,const unsigned int) const' with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\archive\detail\iserializer.hpp(1 72) : see reference to class template instantiation 'boost::archive::detail::iserializer<Archive,T>' being compiled with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\archive\detail\iserializer.hpp(1 71) : while compiling class-template member function 'const boost::archive::detail::basic_iserializer &boost::archive::detail::pointer_iserializer<T,Archive>::get_basic_seria lizer(void) const' with [ T=D2::Message, Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head ] C:\boost\boost-cvs-20050606\boost\boost\archive\detail\iserializer.hpp(5 01) : see reference to class template instantiation 'boost::archive::detail::pointer_iserializer<T,Archive>' being compiled with [ T=D2::Message, Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(78) : see reference to function template instantiation 'const boost::archive::detail::basic_pointer_iserializer &boost::archive::detail::instantiate_pointer_iserializer<Archive,T>(Arch ive *,T *)' being compiled with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(74) : while compiling class-template member function 'void boost::archive::detail::export_impl::archive<Archive,T>::i::invoke(void) ' with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(105) : see reference to class template instantiation 'boost::archive::detail::export_impl::archive<Archive,T>::i' being compiled with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(89) : while compiling class-template member function 'void boost::archive::detail::export_impl::archive<Archive,T>::instantiate(voi d)' with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(116) : see reference to class template instantiation 'boost::archive::detail::export_impl::archive<Archive,T>' being compiled with [ Archive=boost::archive::detail::export_impl::for_each_archive<boost::arc hive::detail::export_impl::for_each_archive<boost::archive::detail::know n_archive_types::type,D2::Message>::tail,D2::Message>::head, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(115) : while compiling class-template member function 'void boost::archive::detail::export_impl::for_each_archive<ASeq,T>::instantia te(void)' with [ ASeq=boost::archive::detail::export_impl::for_each_archive<boost::archiv e::detail::known_archive_types::type,D2::Message>::tail, T=D2::Message ] C:\boost\boost-cvs-20050606\boost\boost\serialization\export.hpp(122) : see reference to class template instantiation 'boost::archive::detail::export_impl::for_each_archive<ASeq,T>' being compiled with [ ASeq=boost::archive::detail::export_impl::for_each_archive<boost::archiv e::detail::known_archive_types::type,D2::Message>::tail, T=D2::Message ] Marcin Tustin IT Innovation Centre 2 Venture Road Chilworth Science Park Southampton, SO16 7NP, UK tel: +44 23 8076 0834 fax: +44 23 8076 0833 mailto:mt@it-innovation.soton.ac.uk http://www.it-innovation.soton.ac.uk

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 <TriumphSprint2000 <at> hotmail.com> 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.

Marcin Tustin wrote:
Jeff Flinn <TriumphSprint2000 <at> hotmail.com> 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