Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-12-10 01:23:05


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_at_[hidden]> wrote in message
news:41B8C1AB.8030507_at_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_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net