Serialization: Cannot use name-value-pairs with indirectly serialized maps.

Hello, While evaluating the serialization library, I've ran into a problem while modifying my code to add name value pairs to the serialized objects in order to be able to serialize them to an xml file. before doing this, everything worked fine, but now that I'm using NVPs, I get the following error: c:\projects\dev_tools\libs\c++\boost_1_32_0\boost\serialization\access.hpp(106): error C2039: 'serialize' : is not a member of 'std::map<_Kty,_Ty>' with [ _Kty=std::string, _Ty=std::string ] I'm using VC 7.1, and a stripped-down but compilable version of the code that causes the problem is included at the end of this mail. I'm really puzzled at this problem as the following modifications to the code will have things compile: -) Comment out only the 'oa << BOOST_SERIALIZATION_NVP(instanceOfB);' line. -) Comment out only the 'ia >> BOOST_SERIALIZATION_NVP(instanceOfB);' line. -) Serializing and unserializing directly the instanceOfA object instead. -) redefining BOOST_SERIALIZATION_NVP to 'BOOST_SERIALIZATION_NVP(x) x' is this really a bug or am I missing something ? Thanks! Martin ------------------------------------------------------------------------ #include <iostream> #include <fstream> #include <string> #include <boost/serialization/map.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> using namespace std; class A { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */) { ar & BOOST_SERIALIZATION_NVP(mappedData_); } map<string, string> mappedData_; }; class B { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */) { ar & BOOST_SERIALIZATION_NVP(privateInstanceOfA_); } A privateInstanceOfA_; }; int main(void) { A instanceOfA; B instanceOfB; std::ofstream ofs("test.txt"); boost::archive::text_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(instanceOfB); std::ifstream ifs("test.txt"); boost::archive::text_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(instanceOfB); } -- Tel: (450) 681-1681, #271 ------------------------------------------------------------------------ OKIOK Enterprise and e-business security solutions Solutions de sécurité d'entreprise et d'affaires électronique Tel. : (450) 681.1681 http://www.okiok.com This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary, confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. Si ce message vous a été transmis par erreur, veuillez en informer l'expéditeur et le supprimer immédiatement.

signatureHmm, I just compiled it with VC 7.1, it passes gcc 3.3 and borland 5.64 as well. Note, my personal version is 1.32+ so that could explain it It did fail for me (with the same error) with Comeau - same message more or less ? Its a mystery to me. Does test_map pass in your environment? Robert Ramey "Martin Proulx" <mproulx@okiok.com> wrote in message news:41B8C1AB.8030507@okiok.com... Hello, While evaluating the serialization library, I've ran into a problem while modifying my code to add name value pairs to the serialized objects in order to be able to serialize them to an xml file. before doing this, everything worked fine, but now that I'm using NVPs, I get the following error: c:\projects\dev_tools\libs\c++\boost_1_32_0\boost\serialization\access.hpp(1 06): error C2039: 'serialize' : is not a member of 'std::map<_Kty,_Ty>' with [ _Kty=std::string, _Ty=std::string ] I'm using VC 7.1, and a stripped-down but compilable version of the code that causes the problem is included at the end of this mail. I'm really puzzled at this problem as the following modifications to the code will have things compile: -) Comment out only the 'oa << BOOST_SERIALIZATION_NVP(instanceOfB);' line. -) Comment out only the 'ia >> BOOST_SERIALIZATION_NVP(instanceOfB);' line. -) Serializing and unserializing directly the instanceOfA object instead. -) redefining BOOST_SERIALIZATION_NVP to 'BOOST_SERIALIZATION_NVP(x) x' is this really a bug or am I missing something ? Thanks! Martin #include <iostream> #include <fstream> #include <string> #include <boost/serialization/map.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> using namespace std; class A { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */) { ar & BOOST_SERIALIZATION_NVP(mappedData_); } map<string, string> mappedData_; }; class B { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int /* file_version */) { ar & BOOST_SERIALIZATION_NVP(privateInstanceOfA_); } A privateInstanceOfA_; }; int main(void) { A instanceOfA; B instanceOfB; std::ofstream ofs("test.txt"); boost::archive::text_oarchive oa(ofs); oa << BOOST_SERIALIZATION_NVP(instanceOfB); std::ifstream ifs("test.txt"); boost::archive::text_iarchive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(instanceOfB); } -- Tel: (450) 681-1681, #271 OKIOK Enterprise and e-business security solutions Solutions de sécurité d'entreprise et d'affaires électronique Tel. : (450) 681.1681 http://www.okiok.com This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary, confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. Si ce message vous a été transmis par erreur, veuillez en informer l'expéditeur et le supprimer immédiatement. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Robert Ramey wrote:
signatureHmm, I just compiled it with VC 7.1, it passes gcc 3.3 and borland 5.64 as well. Note, my personal version is 1.32+ so that could explain it
Fails for me on VC7.1 with 1.32.
It did fail for me (with the same error) with Comeau - same message more or less ?
Adding #define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP allows it to compile and link. I haven't tried running it. As I previously reported I've had similar problems when serialising std::set<string>'s. Jeff

Jeff Flinn wrote:
Robert Ramey wrote:
signatureHmm, I just compiled it with VC 7.1, it passes gcc 3.3 and borland 5.64 as well. Note, my personal version is 1.32+ so that could explain it
Fails for me on VC7.1 with 1.32.
It did fail for me (with the same error) with Comeau - same message more or less ?
Adding
#define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
allows it to compile and link. I haven't tried running it. As I previously reported I've had similar problems when serialising std::set<string>'s.
Jeff
This does the trick for me as well. I'm now able to serialize things to XML! Thanks! Martin

Robert Ramey wrote:
signatureHmm, I just compiled it with VC 7.1, it passes gcc 3.3 and borland 5.64 as well. Note, my personal version is 1.32+ so that could explain it
It did fail for me (with the same error) with Comeau - same message more or less ?
Its a mystery to me. Does test_map pass in your environment?
Robert Ramey
Yes, all the boost synchronization tests do compile and pass. Martin
participants (3)
-
Jeff Flinn
-
Martin Proulx
-
Robert Ramey