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
#include
#include
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 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.